I'm using jqGrid version 4.5.2 and jquery 1.9.1 as well as MVC 4.
The grid I'm using has about 2000 rows total, and I'm displaying 100 of them at a time. I'm using virtual grid scroll, not pagination, with the following grid definition:
$("#colorsGrid").jqGrid({
url: '@Url.Action("Colors")',
//datatype: 'xml',
datatype: 'json',
colNames: ['id', 'RGB', 'FS', 'RAL', 'Humbrol', 'Revell', 'Tamiya', 'RLM', 'Vallejo', 'Testors / Model Master','ANA','Games Workshop / Citadel'],
colModel: [
{ name: 'id', index: 'id', hidden: true },
{ name: 'RGB', sorttype: rgbColorSorter, formatter: rgbColumnFormatter, width: 70 },
{ name: 'FS', sorttype: colorSorter, formatter: colorFormatter, width: 200 },
{ name: 'RAL', sorttype: colorSorter, formatter: colorFormatter, width: 200 },
{ name: 'Humbrol', sorttype: colorSorter, formatter: colorFormatter, width: 200 },
{ name: 'Revell', sorttype: colorSorter, formatter: colorFormatter, width: 200 },
{ name: 'Tamiya', sorttype: tamiyaColorSorter, formatter: colorFormatter, width: 200 },
{ name: 'RLM', sorttype: colorSorter, formatter: colorFormatter, width: 200 },
{ name: 'Vallejo', sorttype: colorSorter, formatter: colorFormatter, width: 200 },
{ name: 'Testors / Model Master', sorttype: colorSorter, formatter: colorFormatter, width: 200 },
{ name: 'ANA', sorttype: colorSorter, formatter: colorFormatter, width: 200 },
{ name: 'GamesWorkshop', sorttype: colorSorter, formatter: colorFormatter, width: 200 }
],
rowNum: 50,
scroll: 1,
emptyrecords: "No colors found",
loadonce: false,
autowidth: false,
sortable: true,
afterInsertRow: afterInsertRowFunction,
multipleSearch: true,
ignoreCase: true,
postData: { filterText: function () { return $('#colorFilter').val(); }},
loadComplete: function () {
if (!resizeGridOnLoadComplete) {
resizeGridOnLoadComplete = true;
resizeGrid();
}
}
The function afterInsertRowFunction only sets some css style for the row. The resizeGrid function only calls setGridHeight on the grid to dynamically fix the height.
On the controller side i'm returning just the number of rows and not the entire dataset as requested in the Request.QueryString parameters, along with the total number of records and pages. Abbreviated example:
{"page":1,"total":38,"records":1918,"rows":[{"id":1,"cell":["1","654037","^10075^10075^^~","","","","","","","","4F2E26^510^510 - Maroon^gloss^Pre/Early WWII~",""]},{"id":2,"cell":["2","7c3925","^10076^10076 - Coast Guard Deck Red, Metallic Red-Brown^^~","","","","","","","","",""]},
My problem is that the following happens: 1. On loading the page, jqGrid sends get an ajax request for page no.1 2. After scrolling past the initial 50 rows, jqgrid sends an ajax request for page no. 2 3. After scrolling past the next 50 rows, jqgrid sends an ajax request for page no.2 again instead of page no.3
If I keep scrolling, then jqGrid will send a request for page no.3 (which should have been page no.4 by now).
Due to the duplicate request and sending back the same data, it messes up the grid.
Things I've tried: Either xml or json format. Leaving the minimum settings on the jqGrid element. Different number of rows in rowNum. Scroll parameter as "true".
I've seen people mention something very similar but it was two years and two versions ago of jqGrid, and was fixed.
Why is jqGrid sending duplicate requests for the same page ?