【发布时间】:2013-07-17 13:13:31
【问题描述】:
要求
每次对网格数据进行排序 - 在事件执行之前,我想用新的排序属性的值更改存储 extraParams。就像如果我在 DESC 方向对列 Name 进行排序 - 在事件执行之前我想用 @987654324 覆盖商店的 extraParams @of Name 列和方向属性DESC。
我的商店也将remoteSort 属性设置为true。
我正在使用 ExtJS 4.2。
问题
我在网格上尝试了sortchange 事件侦听器,但它在调用数据 API 并加载记录后执行。我想要的是像 beforesortchange 这样的东西。
这都是remoteSort : true。
下一个问题是,如果我从 sortchange 调用 this.getStore().load();,那么我的数据 api 会被调用两次,这是没有意义的。
代码
网格监听器:
sortchange: function(ct, column, direction, eOpts) {
this.getStore().getProxy().extraParams = {
'sort' : column.dataIndex,
'dir' : direction
}
// load() will call the data api again once the data loading is over
//this.getStore().load();
}
我也尝试过关注网格侦听器,但要么我没有获得新的网格排序参数,要么根本没有调用它们:
beforeload、beforesync、beforeprefetch、load。
参考文献
【问题讨论】: