如何从定义之外更改组合框(ExtJS)的模型
How to change model of a combobox (Ext JS) from outside its definition
我这里有两个Ext组合框,当调用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,
}
对于第二个组合框,为每个模型类型配置一个组合框。在第一个组合框中进行选择时,隐藏或显示相应的组合框。
如果您需要完全更改数据(JSFiddle)
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;
}
如果您只需要过滤(加载)第二个组合框中的数据,您可以执行类似的操作
在第一个组合框的选择事件上,准备第二个组合框来过滤数据
combobox2.queryData = [{ property: 'fieldName', value: value}];
combobox2.reset();
combobox2.doQuery(combobox.queryData);
其中CCD_ 1是对激活的组合的引用,而CCD_。为了确保使用您的新查询,请使用
combobox2.on('beforequery', function (e) {
e.query = e.combo.queryData;
});
相关文章:
- 如何将本地json数据加载到Extjs数据模型中
- ExtJS 4:编写带有模型关联的嵌套XML
- 在extJS 4.2中,有没有一种方法可以将模型值动态绑定到表单
- 将 ExtJS 代理 AJAX 响应映射到模型
- 字符串映射的Extjs模型数组
- 嵌套的XML数据和ExtJS模型关联
- 如何忽略ExtJS数据模型中的空字段
- 我可以使用sencha extjs商店和模型进行sencha触摸吗
- 通过 id-Extjs 将数据加载到模型中
- 在 ExtJS 4 应用程序之间共享模型
- ExtJS 5:父模型转换对子关联的依赖关系
- 在 extjs 3.3.1 列模型中打印未隐藏的列
- 如何为此 xml 格式创建 EXTJS 模型
- 尝试在列模型 ExtJS 3.3.1 中记录隐藏和非隐藏列
- ExtJS网格选择模型
- Extjs使用复选框模型在网格上拖放单个项目
- 如何从模型存储EXTJs中读取额外属性
- 如何实现期望接收对象列表的Extjs模型
- 如何绑定 ExtJS 模型和挖空模板
- extjs模型覆盖