我这里有两个扩展组合框,当调用combobox1的select事件时,我需要更改第二个组合框的值,我的问题是我不知道如何更改组合框的模型。
items: [{
xtype:'combo',
fieldLabel: 'Course',
afterLabelTextTpl: required,
store: new Ext.data.SimpleStore({
data: [
[1, 'Bsc CS'],
[2, 'MSc CS'],
],
id: 0,
fields: ['value', 'text']
}),
name: 'first',
listeners:{
select: function( combo, records, eOpts )
{
if(this.getValue()=="Bsc CS")
{
// Ext.get('semcombo').getStore.loadData(msc);
}
else if(this.getValue()=="MSc CS")
{
}
}
},
editable:false,
allowBlank: false
},{
xtype:'combo',
fieldLabel: 'Semester',
id : 'semcombo',
afterLabelTextTpl: required,
name: 'last',
allowBlank: false,
}发布于 2013-02-19 11:02:12
对于第二个组合框,为每个模型类型配置一个组合框。在第一个组合框中进行选择时,隐藏或显示适当的组合框。
发布于 2013-02-19 16:11:05
如果需要完全更改data ()
select: function(checkbox,records) {
comp.clearValue();
comp.bindStore(Ext.StoreMgr.lookup(records[0].data.store));
// you can change the value field if needed
comp.displayField = 'petname';
// you can change the display field if needed
comp.valueField = 'id';
// you can change the display template if needed
comp.displayTpl = new Ext.XTemplate(
'<tpl for=".">' +
'{[typeof values === "string" ? values : values["' + comp.displayField + '"]]}' +
'<tpl if="xindex < xcount">' + comp.delimiter + '</tpl>' +
'</tpl>'
);
comp.picker = null;
}如果你只是需要过滤(加载)第二个combox中的数据,你可以这样做
在第一个组合框的select事件上,准备第二个组合框以过滤数据
combobox2.queryData = [{ property: 'fieldName', value: value}];
combobox2.reset();
combobox2.doQuery(combobox.queryData);其中combobox2是对激活的组合的引用,value是组合中的属性值。要确保使用新的查询,请使用
combobox2.on('beforequery', function (e) {
e.query = e.combo.queryData;
});https://stackoverflow.com/questions/14940977
复制相似问题