I have a very specific problem: I have a small form with four options. You can fill them out or not, and when you click "Ok", I load jqGrid with data depending on these parameters. But since I donβt know what my columns look like, I let my servlet generate the column model and column name; so I have to make an AJAX request to load the data, and then populate it in jqGrid as "local" data. I would like to use pagination.
So my question is: how to load more data into jqGrid after it is already installed through local data?
here is the code:
$.ajax({ type : 'GET', url : 'data.jsp', data : reqData, dataType : 'json', error: function() { $("#dialog-message").dialog("open"); $("#ajax-loader").css("display", "none"); }, success : function(result) { jQuery("#results").jqGrid({ data : result.rows, datatype : "local", colNames : result.columnNames, colModel : result.columnModel, pager : $('#pager'), rowNum : 1000, scroll : true, viewrecords : true, sortname : 'TITEL', width : window.innerWidth - 30, height : window.innerHeight - 190, altRows : true, loadError: function() { $("#dialog-message").dialog("open"); $("#ajax-loader").css("display", "none"); }, loadComplete: function() { $("#ajax-loader").css("display", "none"); } }).jqGrid("navGrid", "#pager", { edit: false, add: false, del: false, search: true, refresh: false }).jqGrid("gridResize"); } });
/ edit: I tried to do the following, but this still does not solve the problem, that the grid does not know how many pages are actually (actually, at that moment I donβt even know), and also, after loading, it considers that it receives only local data. Maybe an onScroll event or something else? I did not find it.
datatype : !json ? "local" : function(postdata) { $.ajax({ type: 'GET', url: 'data.jsp', data: $.merge(postdata, reqData), dataType: 'json', success: function(data, status, jqXHR) { var mygrid = jQuery("#results")[0]; var myjsongrid = eval("("+jqXHR.responseText+")"); mygrid.addJSONData(myjsongrid); } }); },