ExtJS不使用我的网格过滤器覆盖
ExtJS is not using my grid filter override
我有一个项目,我需要做一个自定义网格日期过滤器。
在有状态保存之前一切正常。我需要为状态添加一个自定义值。我从扩展Ext.util.Filter
的类重写了getState
方法:
Ext.define('RelativeDateUtilFilter', {
extend: 'Ext.util.Filter',
getState: function () {
var config = this.getInitialConfig(),
result = {},
name;
for (name in config) {
if (config.hasOwnProperty(name)) {
result[name] = config[name];
}
}
delete result.root;
result.value = this.getValue();
//this is the line I added
result.relValue = this.relValue;
this.callParent();
return result;
}
});
我有一个过滤器基类的重写,使它使用我自己的util过滤器:
createFilter: function (config, key) {
var filter = new RelativeDateUtilFilter(this.getFilterConfig(config, key));
filter.isGridFilter = true;
return filter;
}
问题是,RelativeDateUtilFilter
类中的getState
仅在我第一次创建过滤器时被调用。当ExtJS保存状态时,它使用基类Ext.util.Filter
中的状态。
我可以通过将我的代码直接放在Ext.util.Filter
类中来解决问题,但我不想这样做,因为它在我想升级的情况下不好。
简而言之,在编写状态时如何强制ExtJS使用我自己的getState
方法?
任何帮助都是感激的!
<标题>编辑:如果这对某人有帮助,我通过删除我的RelativeDateUtilFilter
类和我的过滤基础覆盖来修复这个问题,并将我的getState
方法放在覆盖文件中:
Ext.define('Override.util.Filter', {
override :'Ext.util.Filter',
getState: function () {
var config = this.getInitialConfig(),
result = {},
name;
for (name in config) {
// We only want the instance properties in this case, not inherited ones,
// so we need hasOwnProperty to filter out our class values.
if (config.hasOwnProperty(name)) {
result[name] = config[name];
}
}
delete result.root;
result.value = this.getValue();
if(this.relValue) {
result.relValue = this.relValue;
}
return result;
}
});
(在/覆盖/util/Filter,js文件中,所以它被SenchaCMD正确加载)
再次感谢@子弹列车!
标题>我相信在您的情况下,您不需要this.callParent();作为重写方法的一部分,这里有一个关于重写方法的不同方法的很好的解释https://sencha.guru/2015/01/20/overriding-methods-safely/
相关文章:
- 使用按钮的Angular UI网格过滤器
- 单击辐射网格过滤器时不会打开下拉列表
- 如何使用angularjs在剑道网格过滤器文本框中应用电话号码掩码
- 剑道UI网格过滤器日期格式
- ExtJS 5.1 - 网格与网格过滤器插件在网格重新配置后中断
- Extjs 网格过滤器使用 store.filter
- 在 Dojo 的服务器端增强网格过滤器插件
- DHTMLX网格过滤器复位后的初始化延迟
- Kendo UI网格-过滤器-日期范围
- 光滑网格过滤器不工作在IE
- 网格过滤器与文本字段extjs
- 如何改变图标或图标的颜色在剑道ui网格过滤器
- 动态列上的剑道网格过滤器
- ExtJS不使用我的网格过滤器覆盖
- $watchCollection在ui网格过滤器
- 剑道网格过滤器布尔值
- 剑道网格过滤器事件与OData
- EXT JS 4.0.2a >网格过滤器>UI bug
- ExtJS网格过滤器没有出现
- ExtJS——网格过滤器在4.2.2中不工作