I am having an issue with a JQGrid losing records when a column sort occurs. For example, if there are 400 records, when the sort occurs, the record count drops to 20.
$("#grdCaseFind").jqGrid({
datatype: "local",
height: 250,
colNames:['SeqNo', 'Report Title', 'Location', 'Status', 'Date', 'Officer Name', 'Incident No.'],
colModel:[
{name:'SeqNo',index:'SeqNo', hidden:true},
{name:'RepTitle',index:'RepTitle', align:"center", width:200},
{name:'CaseAddr',index:'CaseAddr', align:"center", width:200},
{name:'RepStatus',index:'RepStatus', align:"center", width:50},
{name:'CaseBeginDate',index:'CaseBeginDate', width:70, align:"center"},
{name:'RepOfficerName',index:'RepOfficerName', width:100, align:"center"},
{name:'IncidentNo',index:'IncidentNo', width:80, align:"center"},
],
multiselect: false,
caption: "",
onSelectRow: function (rowid, status) {
if (status === false) {
$(this).resetSelection();
$("#btnOpen").attr("disabled", true);
} else {
$("#btnOpen").attr("disabled", false);
$("#CaseSelectedIndex").val($("#grdCaseFind").getCell(rowid, "SeqNo"))
}
},
ondblClickRow: function (rowid, iRow, iCol, e) {
document.getElementById("btnOpen").click();
},
onSortCol: function (index, iCol, sortoder) {
$("#btnOpen").attr("disabled", true);
}
});
The data is filled from a JSON array stored on the form itself.
grdCaseFindData = strFindResult.grdCaseFind;
$(grdCaseFindData).each(function (i, e) {
$("#grdCaseFind").addRowData(i + 1, e);
$("#grdCaseFind").attr("rowNum", i + 1);
});
I ran into this issue before, and by counting the records and setting the “rowNum” attribute, the issue was corrected. In my other grids, the only difference is that I am loading the records via a call to the server, which returns a JSON array. Any ideas of why this grid is not behaving like the others?
Disregard the question. Apparently there is an issue with setting the rowNum attribute dynamically after the grid is initialized. The only work around I found to this was to either
Which only works in earlier versions of JQGrid, or
Which is the maxInt size, an astronomically high number that is not likely to be reached.
If anyone knows a more elegant and current solution, please correct my answer.