Uchenna Nwanyanwu
Uchenna Nwanyanwu

Reputation: 3204

How to load all the records from the server in jqgrid

I have a grid which gets its data from the server. I don't need paging on this grid, i want all the records loaded at once. I have tried using loadonce attribute, but it doesn't work. How can i achieve this?

This is my grid

jQuery("#rowed4").jqGrid({
    url:'server.php?q=2',
    datatype: "json",
    colNames: ['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], 
    colModel: [
        {name:'id',index:'id', width:55}, 
        {name:'invdate',index:'invdate', width:90, editable:true}, 
        {name:'name',index:'name', width:100,editable:true}, 
        {name:'amount',index:'amount', width:80, align:"right",editable:true}, 
        {name:'tax',index:'tax', width:80, align:"right",editable:true}, 
        {name:'total',index:'total', width:80,align:"right",editable:true}, 
        {name:'note',index:'note', width:150, sortable:false,editable:true}
    ], 
    rowNum: 10,
    rowList: [10, 20, 30],
    pager: '#prowed4',
    sortname: 'id',
    viewrecords: true, 
    sortorder: "desc",
    editurl: "server.php",
    caption: "Full control"
});

Upvotes: 0

Views: 4624

Answers (1)

Oleg
Oleg

Reputation: 222017

If you don't use loadonce: true the server should return the first page of data only. In your case you use rowNum: 10. So the server should return maximal 10 records. So the server should return the subset of result based on page and rows parameter sent by jqGrid to the server

If you use loadonce: true the server should return all records. The server should ignore page and rows parameter sent by jqGrid. jqGrid will save all the data in the internal parameters data and _index and will implement for you paging, sorting and filtering/searching locally (without any additional requests to the server).

The rest should work automatically.

Upvotes: 4

Related Questions