I want to reorder jqGrid columns by column name
or by column index (string)
not by column index (int)
. I have seen this API
$("#list").jqGrid("remapColumns", [0,1,12,3,14,5,6,7,8,11,2], true);
It uses column index number but the problem is after altering the order jqGrid do a reindex and change the index. So i'm looking for the API which accept column name instead of integer value.
This is my code to get the column name
var columnModels = grid.jqGrid('getGridParam', 'colModel');
var user_visibalColumn = [];
for (var columnModelIndex in columnModels) {
var columnModel = columnModels[columnModelIndex];
if (!columnModel.hidden) {
user_visibalColumn.push(columnModel.name);
}
}
//console.log(user_visibalColumn);
So after some time on an event I want to trigger getGridParam
with the above user_visibalColumn
array column.
Is this possible? If not then is there are way to add HTML data-tag col-id so that I can retrieve col-id.
I have seen this answer but I cannot able to figure out how to just implement restoreColumnState
.
Any suggestion will be very helpful.
Thanks.