Reputation: 12347
Continuing from my previous question which was solved by @Oleg.
The solution seems to work when the data is less, but when the increased, it is behaving somewhat same as my previous problem.
Initially the grid displays only two groupings (actually 3), when I go to next page (2 pages in total, each page contains 14 rows) it shows 1 grouping, but when I come back to my initial page, (after hitting the pagination) now it displays all the 3 groupings. Please help fixing this problem.
Below are the 3 screen shots (1st before pagination, 2nd after pagination hit, 3rd.. comeback to 1st page).
Update Indifferent behavior when data is large. Now it has 4 groups but one of them is shown in next page.
My jqgrid code var grouping=new Array("Environment", "system", "IIRServers","product");
$('#compareContent').empty();
$('<div id="compareParentDiv">'+
'<table id="list2" cellspacing="0" cellpadding="0"></table>'+
'<div id="gridpager3"></div></div>')
.appendTo('#compareContent');
$("#compareParentDiv").hide();
var gridDiff = $("#list2");
gridDiff.jqGrid({
datastr: compareData,
datatype: "jsonstring",
colNames: ['KeyName', 'SubCategory', starheader, header1,'isEqual'],
colModel: [
{ name: 'elementName', index: 'elementName', width: 150 },
{ name: 'subCategory', index: 'subCategory', width: 1 },
{ name: 'firstValue', index: 'firstValue', width: 300, jsonmap:'attribute.0.firstValue' },
{ name: 'secondValue', index: 'secondValue', width: 300,jsonmap:'attribute.0.secondValue' },
{ name: 'isEqual', index: 'isEqual', width: 1,hidden:true}
],
pager: '#gridpager3',
//rowNum: 14,
scrollOffset:1,
viewrecords: true,
//rownumbers: true,
height: 'auto',
autowidth:true,
grouping: true,
jsonReader: {
repeatitems: false,
page: function(){return 1;},
root: "response"
},
groupingView: {
groupField: ['subCategory'],
groupOrder: ['desc'],
//groupDataSorted : true,
groupColumnShow: [false],
//groupCollapse: true,
groupText: ['<b>{0} - {1} Item(s)</b>']
},
loadComplete: function() {
if (this.p.datatype !== 'local') {
setTimeout(function () {
gridDiff.trigger('reloadGrid');
}, 0);
} else {
$("#compareParentDiv").show();
}
var i, names=this.p.groupingView.sortnames[0], l = names.length;
for (i=0;i<l;i++) {
if ($.inArray(names[i],grouping) >= 0) {
$(this).jqGrid('groupingToggle',this.id+"ghead_"+i);
} else {
// hide the grouping row
$('#'+this.id+"ghead_"+i).hide();
}
}
var i, l, data = this.p.data, rows = this.rows, item;
l = data.length;
for (i=0;i<l;i++) {
item = data[i];
if (!item.isEqual) {
$(rows.namedItem(item._id_))
.css({
"background-color": "#FFE3EA",
"background-image": "none"
});
}
}
}
});
gridDiff.jqGrid('navGrid', '#gridpager3', { add: false, edit: false, del: false, search: false, refresh: true });
my JSON
{
"response": [
{
"id": "1",
"elementName": "rulebaseserver",
"category": "product",
"subCategory": "IIRServers",
"isEqual": false,
"attribute": [
{
"name": "rulebaseserver",
"firstValue": "ssasvck> Server 'benz:7668' is up\u000a",
"secondValue": "ssasvck> Attempt 1 at server 'estilo:45687'\u000assasvck> Server 'estilo:45687' is down\u000a"
}
]
},
{
"id": "2",
"elementName": "xmlsyncserver",
"category": "product",
"subCategory": "IIRServers",
"isEqual": false,
"attribute": [
{
"name": "xmlsyncserver",
"firstValue": "ssasvck> Attempt 1 at server 'localhost:-1'\u000assasvck> Server 'localhost:-1' is down\u000a",
"secondValue": "ssasvck> Attempt 1 at server 'estilo:45689'\u000assasvck> Server 'estilo:45689' is down\u000a"
}
]
},
{
"id": "3",
"elementName": "SSANUL",
"category": "system",
"subCategory": "Environment",
"isEqual": true,
"attribute": [
{
"firstValue": "/dev/null",
"secondValue": "/dev/null"
}
]
},
{
"id": "4",
"elementName": "SSA_LIHOST",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "benz:7660",
"secondValue": "estilo:45682"
}
]
},
{
"id": "5",
"elementName": "SSH_CLIENT",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "10.65.6.131 1402 22",
"secondValue": "10.65.6.131 2138 22"
}
]
},
{
"id": "6",
"elementName": "HOSTTYPE",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"secondValue": "x86_64-linux"
}
]
},
{
"id": "7",
"elementName": "DB2DIR",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/databases/db2v8_32bit"
}
]
},
{
"id": "8",
"elementName": "PWD",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/home/srkalya1/csm",
"secondValue": "/home/hqusers1/csm"
}
]
},
{
"id": "9",
"elementName": "JAVA_LIB",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/home/srkalya1/csm/lib",
"secondValue": "/home/hqusers1/csm/lib"
}
]
},
{
"id": "10",
"elementName": "MACHTYPE",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"secondValue": "x86_64"
}
]
},
{
"id": "11",
"elementName": "NLSPATH",
"category": "system",
"subCategory": "Environment",
"isEqual": true,
"attribute": [
{
"firstValue": "/usr/dt/lib/nls/msg/%L/%N.cat",
"secondValue": "/usr/dt/lib/nls/msg/%L/%N.cat"
}
]
},
{
"id": "12",
"elementName": "SSA_PRODUCT",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "iss",
"secondValue": "iir"
}
]
},
{
"id": "13",
"elementName": "xmlconsoleserver",
"category": "product",
"subCategory": "IIRServers",
"isEqual": false,
"attribute": [
{
"name": "xmlconsoleserver",
"firstValue": "ssasvck> Attempt 1 at server 'localhost:-1'\u000assasvck> Server 'localhost:-1' is down\u000a",
"secondValue": "ssasvck> Attempt 1 at server 'estilo:45691'\u000assasvck> Server 'estilo:45691' is down\u000a"
}
]
},
{
"id": "14",
"elementName": "SHLIB_PATH",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/data/ODBC5.1_32/lib:.:/usr/lib:/lib:/databases/sybase12.5.2_64BIT/OCS-12_5/lib:/databases/oracle9.2.0.6/lib32:/databases/db2v8_32bit/lib:/databases/sybase12.5.2_64BIT/OCS-12_5/lib:/home/srkalya1/IIR_901_HPUX/bin"
}
]
},
{
"id": "15",
"elementName": "numberofcpu",
"category": "system",
"subCategory": "system",
"isEqual": false,
"attribute": [
{
"name": "numberofcpu",
"firstValue": "2\u000a",
"secondValue": "4\u000a"
}
]
},
{
"id": "16",
"elementName": "PATH",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/home/srkalya1/IIR_901_HPUX/bin:/home/srkalya1/IDQ_PC_860_Integration/bin:/bin:.:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/bin:/opt/aCC/bin:/usr/ccs/bin:/usr/local/etc:/etc:/usr/etc:.:/databases/oracle9.2.0.6/bin:/databases/sybase12.5.2_64BIT/OCS-12_5/bin:/databases/db2v8_32bit/bin:/data/ODBC5.1_32/bin",
"secondValue": "/home/hqusers1/IIR_1152825121_estilo_9.0.1SP2_32/bin:/usr/local/bin:/bin:/usr/bin"
}
]
},
{
"id": "17",
"elementName": "avail",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "14635072"
}
]
},
{
"id": "18",
"elementName": "SSATEMP",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/home/srkalya1/tmp",
"secondValue": "/home/hqusers1/tmp"
}
]
},
{
"id": "19",
"elementName": "SSAOPTS",
"category": "system",
"subCategory": "Environment",
"isEqual": true,
"attribute": [
{
"firstValue": "+L",
"secondValue": "+L"
}
]
},
{
"id": "20",
"elementName": "SSA_XMPORT",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "7670",
"secondValue": "45688"
}
]
},
{
"id": "21",
"elementName": "SSA_RBPORT",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "7668",
"secondValue": "45687"
}
]
},
{
"id": "22",
"elementName": "SSA_SEHOST",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "benz:7666",
"secondValue": "estilo:45684"
}
]
},
{
"id": "23",
"elementName": "SSA_SEPORT",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "7666",
"secondValue": "45684"
}
]
},
{
"id": "24",
"elementName": "SSAWORKDIR",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/home/srkalya1/IIR_901_HPUX/ids",
"secondValue": "/home/hqusers1/IIR_1152825121_estilo_9.0.1SP2_32/ids"
}
]
},
{
"id": "25",
"elementName": "NLS_LANG",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "American_America.AL32UTF8"
}
]
},
{
"id": "26",
"elementName": "TZ",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "IST-5:30"
}
]
},
{
"id": "27",
"elementName": "SSAGREP",
"category": "system",
"subCategory": "Environment",
"isEqual": true,
"attribute": [
{
"firstValue": "/bin/grep",
"secondValue": "/bin/grep"
}
]
},
{
"id": "28",
"elementName": "ORACLE_HOME",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/databases/oracle9.2.0.6"
}
]
},
{
"id": "29",
"elementName": "A",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "26214400"
}
]
},
{
"id": "30",
"elementName": "SSABIN",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/home/srkalya1/IIR_901_HPUX/bin",
"secondValue": "/home/hqusers1/IIR_1152825121_estilo_9.0.1SP2_32/bin"
}
]
},
{
"id": "31",
"elementName": "MANPATH",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/usr/share/man/%L:/usr/share/man:/usr/contrib/man/%L:/usr/contrib/man:/usr/local/man/%L:/usr/local/man:/opt/mx/share/man:/opt/sec_mgmt/share/man:/usr/dt/share/man:/opt/samba/man:/opt/resmon/share/man:/opt/gnome/man:/opt/perf/man/%L:/opt/perf/man:/opt/ignite/share/man/%L:/opt/ignite/share/man:/opt/wbem/share/man:/opt/prm/man/%L:/opt/prm/man:/opt/sec_mgmt/share/man/%L:/opt/ssh/share/man:/opt/graphics/common/man:/opt/mqm/man:/opt/sentinel/man/%L:/opt/sentinel/man:/opt/langtools/share/man/%L:/opt/langtools/share/man"
}
]
},
{
"id": "32",
"elementName": "SSA_CSPORT",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "7669",
"secondValue": "1669"
}
]
},
{
"id": "33",
"elementName": "version",
"category": "system",
"subCategory": "system",
"isEqual": false,
"attribute": [
{
"name": "version",
"firstValue": "U\u000a",
"secondValue": "Red Hat Enterprise Linux Server release 5.3 (Tikanga)\u000a"
}
]
},
{
"id": "34",
"elementName": "U",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "11579328"
}
]
},
{
"id": "35",
"elementName": "SSAAWK",
"category": "system",
"subCategory": "Environment",
"isEqual": true,
"attribute": [
{
"firstValue": "/bin/awk",
"secondValue": "/bin/awk"
}
]
},
{
"id": "36",
"elementName": "OCLIB",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/databases/sybase12.5.2_64BIT/OCS-12_5/lib"
}
]
},
{
"id": "37",
"elementName": "TNS_ADMIN",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/home/srkalya1"
}
]
},
{
"id": "38",
"elementName": "LOGNAME",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "srkalya1",
"secondValue": "hqusers1"
}
]
},
{
"id": "39",
"elementName": "SSA_RBHOST",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "benz:7668",
"secondValue": "estilo:45687"
}
]
},
{
"id": "40",
"elementName": "__ARIES_PA_AOUT_MAXSSIZ",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "8388608"
}
]
},
{
"id": "41",
"elementName": "_",
"category": "system",
"subCategory": "Environment",
"isEqual": true,
"attribute": [
{
"firstValue": "/bin/env",
"secondValue": "/bin/env"
}
]
},
{
"id": "42",
"elementName": "xmlsearchserver",
"category": "product",
"subCategory": "IIRServers",
"isEqual": false,
"attribute": [
{
"name": "xmlsearchserver",
"firstValue": "ssasvck> Server 'benz:7670' is up\u000a",
"secondValue": "ssasvck> Attempt 1 at server 'estilo:45688'\u000assasvck> Server 'estilo:45688' is down\u000a"
}
]
},
{
"id": "43",
"elementName": "SSABASEDIR",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/home/srkalya1/IIR_901_HPUX/ids",
"secondValue": "/home/hqusers1/IIR_1152825121_estilo_9.0.1SP2_32/ids"
}
]
},
{
"id": "44",
"elementName": "maxthreadsperproc",
"category": "system",
"subCategory": "system",
"isEqual": false,
"attribute": [
{
"name": "maxthreadsperproc",
"firstValue": " 256 \u000a",
"secondValue": "2000000\u000a"
}
]
},
{
"id": "45",
"elementName": "cpuspeed",
"category": "system",
"subCategory": "system",
"isEqual": false,
"attribute": [
{
"name": "cpuspeed",
"firstValue": "1400\u000a",
"secondValue": " 1862.054\u000a"
}
]
},
{
"id": "46",
"elementName": "mempagesize",
"category": "system",
"subCategory": "system",
"isEqual": true,
"attribute": [
{
"name": "mempagesize",
"firstValue": "4096\u000a",
"secondValue": "4096\u000a"
}
]
},
{
"id": "47",
"elementName": "GROUP",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"secondValue": "support"
}
]
},
{
"id": "48",
"elementName": "connectionserver",
"category": "product",
"subCategory": "IIRServers",
"isEqual": false,
"attribute": [
{
"name": "connectionserver",
"firstValue": "ssasvck> Server 'benz:7667' is up\u000a",
"secondValue": "ssasvck> Attempt 1 at server 'estilo:45685'\u000assasvck> Server 'estilo:45685' is down\u000a"
}
]
},
{
"id": "67",
"elementName": "ssaname3server",
"category": "product",
"subCategory": "IIRServers",
"isEqual": true,
"attribute": [
{
"name": "ssaname3server",
"firstValue": "ssasvck> Attempt 1 at server 'null:-1'\u000assasvck> Server 'null:-1' is down\u000a",
"secondValue": "ssasvck> Attempt 1 at server 'null:-1'\u000assasvck> Server 'null:-1' is down\u000a"
}
]
},
{
"id": "70",
"elementName": "osname",
"category": "system",
"subCategory": "system",
"isEqual": false,
"attribute": [
{
"name": "osname",
"firstValue": "HP-UX\u000a",
"secondValue": "Linux\u000a"
}
]
},
{
"id": "73",
"elementName": "bitmode",
"category": "product",
"subCategory": "product",
"isEqual": false,
"attribute": [
{
"name": "bitmode",
"firstValue": "/home/srkalya1/IIR_901_HPUX/bin/libssaiok.so:\u0009ELF-64 shared object file - IA64\u000a",
"secondValue": "/home/hqusers1/IIR_1152825121_estilo_9.0.1SP2_32/bin/libssaiok.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), not stripped\u000a"
}
]
},
{
"id": "76",
"elementName": "hostname",
"category": "system",
"subCategory": "system",
"isEqual": false,
"attribute": [
{
"name": "hostname",
"firstValue": "benz\u000a",
"secondValue": "estilo\u000a"
}
]
},
{
"id": "77",
"elementName": "machine",
"category": "system",
"subCategory": "system",
"isEqual": false,
"attribute": [
{
"name": "machine",
"firstValue": "ia64 hp server rx2600\u000a",
"secondValue": "x86_64\u000a"
}
]
},
{
"id": "82",
"elementName": "release",
"category": "system",
"subCategory": "system",
"isEqual": false,
"attribute": [
{
"name": "release",
"firstValue": "B.11.23\u000a",
"secondValue": "2.6.18-128.el5\u000a"
}
]
},
{
"id": "83",
"elementName": "SSA_ARCH",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "IA64",
"secondValue": "X86"
}
]
},
{
"id": "84",
"elementName": "ssaname3webserviceserver",
"category": "product",
"subCategory": "IIRServers",
"isEqual": false,
"attribute": [
{
"name": "ssaname3webserviceserver",
"firstValue": "ssasvck> Attempt 1 at server 'null:-1'\u000assasvck> Server 'null:-1' is down\u000a",
"secondValue": "ssasvck> Attempt 1 at server 'null:-1'\u000assasvck> Server 'null:-1' is down\u000a"
}
]
},
{
"id": "91",
"elementName": "__ARIES_PA_STACK_SIZE_cur",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "8388608"
}
]
},
{
"id": "92",
"elementName": "consoleserver",
"category": "product",
"subCategory": "IIRServers",
"isEqual": false,
"attribute": [
{
"name": "consoleserver",
"firstValue": "ssasvck> Server 'benz:7669' is up\u000a",
"secondValue": "ssasvck> Attempt 1 at server 'localhost:1669'\u000assasvck> Server 'localhost:1669' is down\u000a"
}
]
},
{
"id": "98",
"elementName": "maxfilesperproc",
"category": "system",
"subCategory": "system",
"isEqual": false,
"attribute": [
{
"name": "maxfilesperproc",
"firstValue": " 4096\u000a",
"secondValue": "32\u000a"
}
]
},
{
"id": "100",
"elementName": "licenseserver",
"category": "product",
"subCategory": "IIRServers",
"isEqual": false,
"attribute": [
{
"name": "licenseserver",
"firstValue": "ssasvck> Server 'benz:7660' is up\u000a",
"secondValue": "ssasvck> Attempt 1 at server 'estilo:45682'\u000assasvck> Server 'estilo:45682' is down\u000a"
}
]
},
{
"id": "103",
"elementName": "SSA_CXPORT",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "",
"secondValue": "45691"
}
]
},
{
"id": "104",
"elementName": "httpsearchserver",
"category": "product",
"subCategory": "IIRServers",
"isEqual": false,
"attribute": [
{
"name": "httpsearchserver",
"firstValue": "ssasvck> Attempt 1 at server 'localhost:-1'\u000assasvck> Server 'localhost:-1' is down\u000a",
"secondValue": "ssasvck> Attempt 1 at server 'estilo:45690'\u000assasvck> Server 'estilo:45690' is down\u000a"
}
]
},
{
"id": "105",
"elementName": "SSA_COPORT",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "7667",
"secondValue": "45685"
}
]
},
{
"id": "106",
"elementName": "HOME",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/home/srkalya1",
"secondValue": "/home/hqusers1"
}
]
},
{
"id": "107",
"elementName": "ATHANOR_HOME",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "/home/srkalya1/IDQ_PC_860_Integration"
}
]
},
{
"id": "108",
"elementName": "SSA_XMHOST",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "benz:7670",
"secondValue": "estilo:45688"
}
]
},
{
"id": "109",
"elementName": "BITMODE",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "32"
}
]
},
{
"id": "110",
"elementName": "DB2INSTANCE",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "db8inst1"
}
]
},
{
"id": "111",
"elementName": "SSA_HTHOST",
"category": "system",
"subCategory": "Environment",
"isEqual": false,
"attribute": [
{
"firstValue": "",
"secondValue": "estilo:45690"
}
]
}
],
"xls_path": "\\csm\\files\\comparefiles\\compare_output.xls"
}
Upvotes: 0
Views: 2645
Reputation: 221997
It's not a bug in jqGrid. The problem exist because you use datatype: "jsonstring"
with unsorted data (the data are not sorted by 'subCategory'). At the beginning the data will be displayed like it was filled. After you goes back to the first page the data will be already sorted locally by jqGrid. After that you can goes many time on the next page and back to the first page and have the same results.
You can solve the problem in another way. The best will be to fill the items of the myJson
sorted by subCategory
. If you can't do this you can do the following. Just include in the loadComplete
the following lines
if (this.p.datatype !== 'local') {
setTimeout(function () {
gridDiff.trigger('reloadGrid');
}, 0);
}
It will reload the grid immediately after the first filling. At the end of loading the datatype
will be changed to datatype = 'local'
, so no reloading of the grid will be not done any time later. The only disadvantage will be small flicker at the loading of the grid. If needed you can place the grid inside of hidden div at the beginning and make the div visible after the second loading of the grid:
$("#compareParentDiv").hide();
...
gridDiff.jqGrid({
loadComplete: function () {
if (this.p.datatype !== 'local') {
... // see before
} else {
$("#compareParentDiv").show();
}
....
}
};
One more small remark. The data in the elementName
column are not unique (see elementName='maxfilesperproc' and id=8 and id=98). So you should remove key:true
from the elementName
column definition. In the case the id
will be used as the rowid.
The last remark. You can use $.inArray if you test existence of names[i]
in the grouping
array. The changed code fragment could be
for (i = 0; i < l; i++) {
if ($.inArray(names[i], grouping) >= 0) {
$(this).jqGrid('groupingToggle', this.id + "ghead_" + i);
} else {
// hide the grouping row
$('#' + this.id + "ghead_" + i).hide();
}
}
See the modified demo here.
Upvotes: 2