Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi experts,

How to load data in jqGrid pagewise? For example if I have 100000 json records which I need to load in the jqGrid but not all at once because it takes a lot of time. So, I want to load first 500 records at first load of page. And then next 500..next 500 and so on. Could you please give a sample code.

Thanks in advance Ankit
Posted

1 solution

Here is the sample code for paging implementation in jqGrid.
http://trirand.com/blog/jqgrid/jqgrid.html
 
Share this answer
 
Comments
ANKIT_JHA 14-May-13 8:10am    
Diya, I have that link. And following it. But the problem is, grid gets loaded with all the data at once which is making my application slow.
Diya khan 14-May-13 8:23am    
If you use loadonce:true jqGrid change the datatype parameters to 'local' after the first load of data from the grid. All next grid reloading (sorting, paging, filtering) works local. If you want refresh the grid data from the server one you should set loadonce:false and datatype to its original value ('json' or 'xml'). For example:

$("#list").setGridParam({datatype:'json', page:1}).trigger('reloadGrid');

So in case of loadonce:false or no loadonce parameter your server is responsible for sorting and paging of the data. If it is not work you have to verify your server code.
ANKIT_JHA 15-May-13 1:55am    
Hi Diya,

I am doing client side programming. Here is a piece of sample code.


$.ajax({
type: "GET",
url: "http://pro-db1:8090/SimulatorUIService/SimulatorDataService.svc/CISLOCATIONDATAs",
dataType: "json",
data: {},
processdata: true,
crossDomain: true,
async: true,
success: function (result) {
$("#jqGrid").jqGrid(
{

datatype: 'local',
data: result.d,
page: 1,
colNames: colNames,
colModel: colModel,
onSelectRow: function (id) { rowselectdata(id); },
pager: '#pager',
viewrecords: true,
caption: gridCaption,
gridview: false,
loadui: "enable",
rowNum: pageSize,
loadonce: false
});
jQuery("#jqGrid").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false });
jQuery("#jqGrid").jqGrid('filterToolbar');
jQuery("#jqGrid").setGridParam().trigger('reloadGrid');
},

error: function (a, b, c) {

alert(a);
}

});
ANKIT_JHA 15-May-13 1:57am    
Any expert out there. Please help me out.
ANKIT_JHA 15-May-13 2:20am    
Here I am getting all the records (near about 50000)at a time being loaded in back-end of jqGrid. What I want to do is, getting 500 records in each page of grid so that performance increases as it is getting time to load the jqGrid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900