Update What I am guessing for now: the Grid#1 is unloaded and regeneraged. However due to the database server performance, the grid retrieves the un-updated data and regenerate before the actual update happens. I replaced GridUnload to refreshing the page, and sometimes the grid gets updated data, sometimes not. I change the title of it due to the main question has been changed, but I will leave the context as it was before.
I have a jqgrid with an action button (not in jqgrid) which will make the change in database, and unload and recreate the grid with the updated data (repulling from database).
However, there are two different error for this actions. (There are two different grids.)
First, the recreated Grid#1 shows the non-updated data.I found that was working with version jqGrid 4.14.1 (2017-03-20). However, with version 4.14.1(2017-04-04) and version 4.14.1(2017-04-20) do not work properly. As I remember right, I did not change any code after 2017-03-20, but only updated the jqgrid.src.js file. The reason that I updated this file to version 4.14.1(2017-04-04) is due to this issue.
Second, Grid#2 returns with duplicated .ui-jqgrid-pg-left class like the image below(.ui-jqgrid-pg-left is generated as much as I regenerate the grid.) This one is tested only with version 4.14.1(2017-04-20).
This is code for Grid#1
$(document).ready(function () {
LoadLGrid1();
$('#btnUpdateData').click(function () {
UpdateData();
$('#tbDetails').jqGrid("GridUnload");
LoadLGrid1();
});
)};
function LoadLGrid1() {
GridArea = $('#tbDetails');
GridArea.jqGrid({
url: '/Locked/GetLockedDetailsDataSet',
datatype: "json",
contentType: "application/json; charset-utf-8",
mtype: 'GET',
emptyrecords: "There is no locked deals currently.",
colModel: [
{label: 'Locked By', name: 'LockedBy', sorttype: 'text', searchoptions: {clearSearch: true}},
{label: 'Status', name: 'Status', sorttype: 'text', searchoptions: {clearSearch: true}},
{label: 'Locked Date', name: 'LockedDate', sorttype: 'date', searchoptions: {clearSearch: true},
//blahblah
}
],
rowNum: 20,
rowList: [20, 30, 50],
prmNames: {
page:'defaultPageNumber',
rows:'rowsPerPage'
},
forceClientSorting: true,
sortname: 'LockedDate',
rownumbers: true,
viewrecords: true,
loadonce: true,
multiselect: true,
multiPageSelection: false,
pager: true,
searching: {
searchOperators: true,
defaultSearch: 'cn',
closeOnEscape: true,
searchOnEnter: false,
multipleSearch: true
}
});
GridArea.jqGrid('filterToolbar', {
ignoreCase: true,
searchOperators: true
});
GridArea.jqGrid('navGrid', {
edit: false,
add: false,
del: false,
refresh: true,
refreshtext: "Clear Filter",
refreshtitle: "Clear Filter"
});
};
This is code for Grid#2. It does have same structure as #1 but I will put just in case....
$(document).ready(function () {
LoadLGrid2(selectedDealId);
$('#btnUpdateData2').click(function () {
UpdateData();
$('#tbTaskDetails').jqGrid("GridUnload");
LoadLGrid2(selectedDealId);
});
)};
function loadGrid2(selectedDealId) {
tbTaskDataArea = $('#tbTaskDetails');
tbTaskDataArea.jqGrid({
url: '/Tasks/GetTaskDataSet',
postData: {
selectedDeal: selectedDealId
},
datatype: "json",
contentType: "application/json; charset-utf-8",
mtype: 'POST',
emptyrecords: "There is no task associated with the deal currently.",
colModel: [
{ label: 'Task Id', name: 'TaskId', sorttype: 'number', searchoptions: { clearSearch: true }, width: 60, align: 'center' },
{ label: 'Description', name: 'Description', sorttype: 'text', searchoptions: { clearSearch: true }, width: 270 },
{ label: 'Create Date', name: 'CreateDt', sorttype: 'date', searchoptions: { clearSearch: true }, width: 140,
//blahblah
}
],
rowNum: 5,
rowList: [5, 10, 15],
prmNames: {
page: 'defaultPageNumber',
rows: 'rowsPerPage'
},
forceClientSorting: true,
sortname: 'CreateDt',
rownumbers: true,
viewrecords: true,
loadonce: true,
multiselect: true,
multiPageSelection: false,
pager: true,
searching: {
searchOperators: true,
defaultSearch: 'cn',
closeOnEscape: true,
searchOnEnter: false,
multipleSearch: true
}
});
tbTaskDataArea.jqGrid('filterToolbar', {
ignoreCase: true,
searchOperators: true
});
tbTaskDataArea.jqGrid('navGrid', {
edit: false,
add: false,
del: false,
refresh: true,
refreshtext: "Clear Filter",
refreshtitle: "Clear Filter"
});
};
Please help me out to fix this. Thank you!