Extjs7 store使用remoteFilter时自定义过滤条件编码格式
版本
7.4.0
方法
框架默认的远程过滤参数编码函数在proxy类中定义,因此需要自定义Proxy,覆盖encodeFilters方法
Ext.define('My.data.proxy.Ajax', {
extend: 'Ext.data.proxy.Ajax',
alias: 'proxy.my-ajax',
filterParam:'filter_options',
encodeFilters: function (filters) {
// 根据filters构造过滤参数
return ;
}
});
源码参考
- ext-core/data/proxy/Server.js
...
getParams: function(operation) {
...
if (filterParam && filters && filters.length > 0) {
params[filterParam] = me.encodeFilters(filters);
}
return params;
},
...
encodeFilters: function(filters) {
var out = [],
length = filters.length,
encode, i;
for (i = 0; i < length; i++) {
encode |= filters[i].serializeTo(out);
}
// If any Filters return Objects encapsulating their full state, then the parameters
// needs JSON encoding.
return encode ? this.applyEncoding(out) : out;
},
...
applyEncoding: function(value) {
return Ext.encode(value);
},
...