Combobox Extjs4链式组合
我有一套两个组合框。一个是国家组合,另一个是州组合。默认情况下,当我选择一个国家时,states组合存储为空,然后根据组合值字段states combo必须根据第一个组合进行过滤/加载。在Extjs2.0中,无论Extjs4中有什么变化,这都是有效的 乡村商店Combobox Extjs4链式组合,combobox,load,extjs4,store,Combobox,Load,Extjs4,Store,我有一套两个组合框。一个是国家组合,另一个是州组合。默认情况下,当我选择一个国家时,states组合存储为空,然后根据组合值字段states combo必须根据第一个组合进行过滤/加载。在Extjs2.0中,无论Extjs4中有什么变化,这都是有效的 乡村商店 var country_store = Ext.create('Ext.data.Store', { //autoLoad: true, fields: ['id','c_id','c_name'], proxy:
var country_store = Ext.create('Ext.data.Store', {
//autoLoad: true,
fields: ['id','c_id','c_name'],
proxy: {
type: 'ajax',
url: 'country_list.php',
reader: {
type:'json',
root: 'results'
}
},
storeId: 'edu_context_store'
});
国营商店
var state_name = Ext.create('Ext.data.Store', {
autoLoad: true,
fields: ['id','s_id','s_name','parent_country_id'],
proxy: {
type: 'ajax',
url: 'states_list.php',
reader: {
type:'json',
root: 'results'
}
},
storeId: 'state_name'
}))
组合框
{
xtype: 'combo',
id: 'country_combo',
hiddenName: 'country_name',
displayField: 'c_name',
valueField: 'c_id',
fieldLabel: 'Country',
queryMode: 'remote',
allowBlank: false,
triggerAction: 'all',
store: country_store,
width: 450,
selectOnFocus: true,
listeners:{
scope: this,
'select': function(combo, rec, idx){
var country_val = combo.getRawValue();
var states_obj = Ext.getCmp('states_combo');
states_obj.clearValue();
//states_obj.store.load();
states_obj.store.filter('parent_country_id', country_val);
}
}
}, {
xtype: 'combo',
id: 'states_combo',
hiddenName:'state_name',
displayField:'s_name',
valueField:'s_id',
queryMode: 'remote',
fieldLabel: 'State',
cls: 'textlineht',
allowBlank: false,
triggerAction: 'all',
store: states_store,
width: 450
}
有人知道怎么做吗
谢谢
combo.getRawValue()
将返回组合中显示给用户的值,而不是基础id值。请改为尝试combo.getValue()
为什么要将其注释掉//states_obj.store.load();我在状态存储中定义了autoLoad:true属性。^所以它在渲染时加载一次,然后再也不会加载了。这很好。我面临着商店过滤的问题。states_obj.store.filter('parent_country_id',country_val');不工作。谢谢Amalea。请使用combo.getValue()。我可以得到valueField,但是states组合没有过滤。我得到的是Countries和states json数据。比如//Country store({“total”:“2”,“results”:[{“id”:“1”,“c_id”:“US”,“c_name”:“United Kingdom”},{“id”:“UK”,“c_name”:“United”;})//states store({“total”:“2”,“results”:[{“id”:“7”,“s_id”:“nyk”,“s_name”:从文档中,监听器应该这样设置:监听器:{select:{fn:function(){},scope:this}}
,我会尝试用这种语法重新编写它,看看是否有帮助。