<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 上移下移
最新推荐文章于 2019-04-10 10:04:12 发布
本文介绍了一个使用 ExtJS 实现的 Grid 数据操作案例,包括如何通过按钮控制选中记录的上移和下移功能。该方法适用于需要对列表进行简单排序的应用场景。

5020

被折叠的 条评论
为什么被折叠?



