我有一个商店,加载一个网格,显示国家名称,首都,和寒冷的天气。
我还有一个复选框,它根据“寒冷天气”列的“是”值来过滤商店。
当我按下核取方块时,方格会筛选并显示具有“是”的状态,但当我取消核取方块时,它不会有任何动作。
我怎样才能恢复到以前的商店?下面是我的复选框。请帮助。
items: [
{
xtype: 'checkboxfield',
boxLabel: 'Show only Cold State',
scope: this,
handler: function (field, value) {
scope: this,
this.checkValue = field.getValue();
console.log(this.checkValue);
if (this.checkValue == true) {
this.store.filter('Cold', 'Yes');
}
else if (this.checkValue == false) {
}
},
更新代码-执行此操作时,出现此错误
类型错误:未定义tempstore 1
items: [
{
xtype: 'checkboxfield',
boxLabel: 'Show only Cold State',
scope: this,
handler: function (field, value) {
scope: this,
this.checkValue = field.getValue();
console.log(this.checkValue);
if (this.checkValue == true) {
var tempstore1 = Ext.StoreMgr.lookup('store');
tempstore1.filters.add('CheckBoxFilter', new Ext.util.Filter({
property: 'Cold',
value: 'Yes',
root: 'myTable'
}));
console.log('here');
tempstore1.load();
}
else if (this.checkValue == false) {
this.store.filters.removeAtKey('CheckBoxFilter');
}
},
第二次更新-现在出现此错误
类型错误:a.getRoot.call(a,d)未定义
代替
var tempstore1 = Ext.StoreMgr.lookup('store');
我正在使用
var tempstore1 = Ext.getCmp('GridArea1').store;
GridArea1
是网格面板的ID。
第三次更新-现在我收到此错误
var tempstore1 = Ext.getCmp('GridArea1').getStore();
chrome调试器错误...“true”和“here”是我的console.log,“h”部分也是...这是tempstore 1的内容,而不是我的数据...
真的
h {具有侦听器:e、范围:h、载荷:假,事件:对象、事件挂起:错误...}
此处
未捕获的类型错误:无法读取未定义的属性'Cold'
1条答案
按热度按时间vsaztqbk1#
您需要使用
clearFilter()
可以移除特定的筛选(
clearFilter()
会将它们全部移除)。请不要使用store.filter('property_to_filter','value')
方法,而用途:要删除筛选器,请用途:
在文档中没有关于
root: 'data'
的内容要添加到过滤器中,现在它工作了:http://jsfiddle.net/vrVRP/2/