我有一个商店,加载显示国家名称,大写和寒冷天气的网格。如何处理检查和取消选中复选框字段存储在extjs
我也有一个复选框,根据“寒冷天气”栏的Yes值过滤商店。
当我点击复选框时,网格会过滤并显示具有'是'的状态,但是当我取消选中该复选框时,它不执行任何操作。
如何恢复店面以显示以前的店铺?以下是我的复选框字段。请帮忙。
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) {
}
},
更新的代码 - 当我这样做,我得到这个错误
TypeError: tempstore1 is undefined
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');
}
},
月2日更新 - 现在我得到这个错误
TypeError: a.getRoot.call(a, d) is undefined
代替
var tempstore1 = Ext.StoreMgr.lookup('store');
我使用
var tempstore1 = Ext.getCmp('GridArea1').store;
GridArea1
是我的GridPanel的ID。
3日更新 - 现在我得到这个错误与铬调试
var tempstore1 = Ext.getCmp('GridArea1').getStore();
错误......“真”和“这里”是我的console.log,所以是“H”的一部分。 ..这是什么tempstore1拥有的,而不是我的数据..
true
h {hasListeners: e, scope: h, loading: false, events: Object, eventsSuspended: false…}
here
Uncaught TypeError: Cannot read property 'Cold' of undefined
感谢您的答案Pheonix,但这会清除我以前的过滤器。我不想清除之前的过滤器。前面的过滤器是由一个组合框触发的,我在这里没有提到。无论如何,你的灵魂会更容易,但我试图回到之前的过滤器,然后点击复选框。 – EagleFox
@EagleFox更新了答案。 – Pheonix
THanks Pheonix ...我试图实现你的答案,但得到“预期”,“”错误......我可以在处理程序中执行它还是应该创建函数 – EagleFox