JKeane
16 Aug 2011, 10:24 AM
I have a popup window that holds a FormPanel with a handful of fields. One of the things I need to do is link some of the child ComboBoxes so that making a selection in one forces a filter on a subsequent one. I've set up a change event so that the Store of the subsequent combo is filtered (like the ComboBox's doQuery method, but filtering on valueField instead of displayField). However, the filtering only flows to the options after I make a choice, even though I have certified that Store is indeed filtered.
See code below, and the comments next to the two alerts.
Ext.define("CF.view.Edit", {
extend: "Ext.window.Window",
alias: "widget.edit",
title: "Client Fees - Edit",
width: 320,
height: 260,
autoShow: true,
buttonAlign: "left",
initComponent: function () {
this.items = [{
xtype: "form",
frame: true,
fieldDefaults: {
labelWidth: 120
},
items: [{
xtype: "textfield",
name: "companyname",
fieldLabel: "Company/Sponsor"
}, {
xtype: "combo",
name: "productseq",
id: "productseq",
fieldLabel: "Product",
store: new CF.store.Products(),
queryMode: "local",
displayField: "productName",
valueField: "productSeq"
}, {
xtype: "combo",
disabled: false,
name: "feetype",
id: "feetype",
fieldLabel: "Fee Type",
store: new CF.store.FeeTypes(),
queryMode: "local",
displayField: "financeFeeDesc",
valueField: "financeFeeSeq",
forceSelection: true
}, {
xtype: "hiddenfield",
name: "iconproductcode",
id: "iconproductcode"
}, {
xtype: "textfield",
disabled: true,
name: "iconproductname",
id: "iconproductname",
fieldLabel: "ICON Product"
}, {
xtype: "numberfield",
name: "feeamt",
fieldLabel: "Fee ($)",
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false
}, {
xtype: "combo",
name: "feemonth",
fieldLabel: "Month",
queryMode: "local",
forceSelection: true,
store: (function () {
var x = [],
i;
for (i = 0; i < 12; i++) {
x.push([i + 1, Ext.Date.monthNames[i]]);
}
return x;
})()
}, {
xtype: "combo",
name: "feeyear",
fieldLabel: "Year",
queryMode: "local",
forceSelection: true,
store: (function () {
var x = [],
year;
for (year = 2007; year <= (new Date).getFullYear(); year++) x.unshift(year);
return x;
})()
}]
}];
// this.down("#productseq").on("change", function(field,value) {
// //Ext.getCmp("iconproductcode").setValue(null);
// //Ext.getCmp("iconproductname").setValue(null);
// Ext.getCmp("feetype").store.filter(productSeq, value);
// });
// this.down("#feetype").on("change", function(field,value) {
// var icon = field.store.get("");
// Ext.getCmp("iconproductcode").setValue(null).store.filter("iconProductCode",value);
// });
this.on("afterrender", function (w) {
w.down("#productseq").on("change", function (field, value) {
//Ext.getCmp("iconproductcode").setValue(null);
//Ext.getCmp("iconproductname").setValue(null);
alert(Ext.getCmp("feetype").store.getCount()) //displays 160 in my test case
Ext.getCmp("feetype").store.clearFilter(true);
Ext.getCmp("feetype").store.filter("productSeq", value);
alert(Ext.getCmp("feetype").store.getCount()) //now it displays 2 as it should, but this is not reflected in the front-end
});
})
this.buttons = [{
text: 'Save',
action: 'save'
}, {
text: 'Cancel',
scope: this,
handler: this.close
}];
this.callParent(arguments);
}
});
See code below, and the comments next to the two alerts.
Ext.define("CF.view.Edit", {
extend: "Ext.window.Window",
alias: "widget.edit",
title: "Client Fees - Edit",
width: 320,
height: 260,
autoShow: true,
buttonAlign: "left",
initComponent: function () {
this.items = [{
xtype: "form",
frame: true,
fieldDefaults: {
labelWidth: 120
},
items: [{
xtype: "textfield",
name: "companyname",
fieldLabel: "Company/Sponsor"
}, {
xtype: "combo",
name: "productseq",
id: "productseq",
fieldLabel: "Product",
store: new CF.store.Products(),
queryMode: "local",
displayField: "productName",
valueField: "productSeq"
}, {
xtype: "combo",
disabled: false,
name: "feetype",
id: "feetype",
fieldLabel: "Fee Type",
store: new CF.store.FeeTypes(),
queryMode: "local",
displayField: "financeFeeDesc",
valueField: "financeFeeSeq",
forceSelection: true
}, {
xtype: "hiddenfield",
name: "iconproductcode",
id: "iconproductcode"
}, {
xtype: "textfield",
disabled: true,
name: "iconproductname",
id: "iconproductname",
fieldLabel: "ICON Product"
}, {
xtype: "numberfield",
name: "feeamt",
fieldLabel: "Fee ($)",
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false
}, {
xtype: "combo",
name: "feemonth",
fieldLabel: "Month",
queryMode: "local",
forceSelection: true,
store: (function () {
var x = [],
i;
for (i = 0; i < 12; i++) {
x.push([i + 1, Ext.Date.monthNames[i]]);
}
return x;
})()
}, {
xtype: "combo",
name: "feeyear",
fieldLabel: "Year",
queryMode: "local",
forceSelection: true,
store: (function () {
var x = [],
year;
for (year = 2007; year <= (new Date).getFullYear(); year++) x.unshift(year);
return x;
})()
}]
}];
// this.down("#productseq").on("change", function(field,value) {
// //Ext.getCmp("iconproductcode").setValue(null);
// //Ext.getCmp("iconproductname").setValue(null);
// Ext.getCmp("feetype").store.filter(productSeq, value);
// });
// this.down("#feetype").on("change", function(field,value) {
// var icon = field.store.get("");
// Ext.getCmp("iconproductcode").setValue(null).store.filter("iconProductCode",value);
// });
this.on("afterrender", function (w) {
w.down("#productseq").on("change", function (field, value) {
//Ext.getCmp("iconproductcode").setValue(null);
//Ext.getCmp("iconproductname").setValue(null);
alert(Ext.getCmp("feetype").store.getCount()) //displays 160 in my test case
Ext.getCmp("feetype").store.clearFilter(true);
Ext.getCmp("feetype").store.filter("productSeq", value);
alert(Ext.getCmp("feetype").store.getCount()) //now it displays 2 as it should, but this is not reflected in the front-end
});
})
this.buttons = [{
text: 'Save',
action: 'save'
}, {
text: 'Cancel',
scope: this,
handler: this.close
}];
this.callParent(arguments);
}
});