ExtJS4 grid 上移下移

<pre name="code" class="javascript">{
    text : '上移',
    xtype: 'button',
    handler: function() {
        var grid = fieldSet.child("[xtype=gridpanel]");
        var records = grid.getSelectionModel().getSelection();
        for(var i in records) {
            var record = records[i];
            var index = store.indexOf(record);
            if (index > 0) {
                store.removeAt(index);
                store.insert(index - 1, record);
                grid.getView().refresh();
                grid.getSelectionModel().selectRange(index - 1, index - 1);
            }
        }

    }
},{
    text : '下移',
    xtype: 'button',
    handler: function() {
        var grid = fieldSet.child("[xtype=gridpanel]");
        var records = grid.getSelectionModel().getSelection();
        for(var i in records) {
            var record = records[i];
            var index = store.indexOf(record);
            if (index < store.getCount() - 1) {
                store.removeAt(index);
                store.insert(index + 1, record);
                grid.getView().refresh();
                grid.getSelectionModel().selectRange(index + 1, index + 1);
            }
        }

    }
}
 

你可能感兴趣的:(ExtJS4 grid 上移下移)