Let me preface with an explanation of what I was trying to do.
a) I have a date column which has a user friendly string date (i.e. Jan 5, 2010) which is displayed to the user and a hidden column (which is used as the sort index). So my date column is configured like so:
this.m_colModelArray.push({ name: 'date', index: "dateTimeTicks" });
and my hidden index column is like so:
this.m_colModelArray.push({ name: 'dateTimeTicks', hidden: true, hidedlg: true });
Now, I've seen a couple potential bugs which occur when the name of a column is not the same as the index of a column as seen above.
1) When grouping by a column where the column name is not the same as the column index, "Loading" will be displayed and it will not be grouped. In my case, I worked around it by commenting out the following section in addLocalData although it's really just a workaround.
/*if (typeof this.index != 'undefined') {
grindex = this.index;
}*/
2) When the column name is not the same as the column index, I also see an issue with trying to preserve the user's sorting choice. In the onSortCol callback, the column name is given. If I save this setting and then try to use it when creating the grid (using the sample code below) I find that the sort arrow will not be displayed for the correct column and the content will not be sorted. Now, if I instead save the index instead of the name and use that in the call to sortname, the content will be sorted but the arrow will not appear over the column that was chosen by the user. I suspect that the arrow is being put over the hidden column that is being used by the index.
Notes: this.m_gridTable is the jQuery object for the table.this.m_columnSortName is thename saved from the onSortCol callback. Similarly sortorder contains the order from that callback.
this.m_gridTable.jqGrid({
autowidth: true,
colModel: this.m_colModelArray,
colNames: this.m_colNamesArray,
data: this.m_dataArray,
datatype: "local",
grouping: true,
loadonce: true,
onSortCol: sortColumnCallback,
shrinkToFit: true,
sortname: this.m_columnSortName,
sortorder: this.m_columnSortOrder
…..
});
I worked around the problem by using the index for the sortname argument (to get it to sort correctly) and changing the following code in jqgrid:
idn = ts.p.colModel[i].index || ts.p.colModel[i].name;
to
idn = ts.p.colModel[i].index;
in order for the arrow to show up.