If I used remapColumns in columnChooser‘s done event, then I don’t have problem to sort the columns. But when I moved
remapColumns to beforeRequest with a new perm information, see below:
beforeRequest: function(){
perm = {0:2,1:0,2:1,3:3,4:4,5:5,6:6,7:7,8:8,9:9,10:10};
myGrid.jqGrid("remapColumns", perm, true);
}
The columns are correctly reordered, and I can search column value, but the column sorting function was just disabled. The click event seems not working. Can somebody help? How can I get it back?
Really appreciate it.
Thanks very much!
Yan
In the answer you can find an example how to use
remapColumnsand I hope another helpful information for you. In the demo I useremapColumnsonce inside ofloadComplete. I don’t understand why you want to change the column order on every request to the server.UPDATED: The modified demo don’t have the effect which you described. The reason was that one called in the old demo the method
remapColumnswith empty ([]) permutation parameter andremapColumnsworks incorrect in the case. So I included additional test formyColumnsState.permutation.length > 0.UPDATED 2: Free jqGrid provides the method
remapColumnsByNameadditionally toremapColumns. The first parameter ofremapColumnsByNameis array of column names, which should be on the grid. Columns"subgrid","cb"and"rn"could be included or not. The understanding of the usage ofremapColumnsByNameis much more easy as the usage ofremapColumnsespecially in situations where the order of columns could be changes by the user (bycolumnChooser, wor example). It’s strictly recommended to useremapColumnsByNameinstead ofremapColumns.