jqGrid: is there an event for when columns are reordered?

前端 未结 7 2285
走了就别回头了
走了就别回头了 2021-02-09 15:09

I\'m using the column reordering feature in jqGrid

$grid = jQuery(\"#list\").jqGrid({
    sortable:true,
    ...
});

Is there an event that fir

7条回答
  •  情歌与酒
    2021-02-09 15:21

    There is a call in grid.jqueryui.js (jqGrid v3.8.2) in update() to ts.p.sortable.update() as discussed on the jqGrid message board, so:

    jQuery('#gridId').jqGrid({
        ...,
        sortable: { update: function(permutation) {
            alert('save permutation somewhere');
        },
        ...
    });
    

    However, please note that the array passed to your callback will be relative to the current column order. In other words, saving the array as is after moving multiple columns will not produce the desired results.

    I had to do something like this:

    var defaultColNames = [ 'Alpha', 'Beta', 'Gamma' ];
    var defaultColModel = [
        { name: 'alpha', index: 'alpha' },
        { name: 'beta', index: 'beta' },
        { name: 'gamma', index: 'gamma' }
    ];
    
    jQuery('#gridId').jqGrid({
        ...,
        colNames: defaultColNames,
        colModel: defaultColModel,
        sortable: { update: function(relativeColumnOrder) {
            var grid = jQuery('#gridId');
    
            var defaultColIndicies = [];
            for( var i=0; i

提交回复
热议问题