我定义了一个联动菜单,两个combobox,都是从后台数据库取值,用的都是proxy,reader,store这种方式,触发第一个combobox之后给第二个combobox的store传参数赋值,代码这样:
Ext.getCmp("combotopodetail").on('select',function(comboBox){
alert("click");
var selecttopodetail = comboBox.getValue();
paramvalue_store.load({params:{topologydetail:selecttopodetail}});
//paramvalue1_store.load({params:{topologydetail:selecttopodetail}});
comboparamvalue.clearValue() ;
//comboparamvalue1.clearValue() ;
});但是第二个combobox是在一个button的handler中定义的,这样触发的时候就死活提示第二个combobox的store is not defined。
求教,我要怎么样操作才能给第二个store赋值?有没有定义类似全局变量的方式?
Ext.getCmp("combotopodetail").on('select',function(comboBox){
alert("click");
var selecttopodetail = comboBox.getValue();
paramvalue_store.load({params:{topologydetail:selecttopodetail}});
//paramvalue1_store.load({params:{topologydetail:selecttopodetail}});
comboparamvalue.clearValue() ;
//comboparamvalue1.clearValue() ;
});但是第二个combobox是在一个button的handler中定义的,这样触发的时候就死活提示第二个combobox的store is not defined。
求教,我要怎么样操作才能给第二个store赋值?有没有定义类似全局变量的方式?
第二个combox和第一个一样在初始化的时候就定义好了,只是第二个数据是空的
在第二个选择的时候就为store赋值即可
eg: var c = new Ext.form.ComboBox({
.....
listeners: {
select: function () {
ds.reload({params: {....}});//如果找不到ds,将ds移到当前combox的上面
//or ds.load({params: {....}});
}
}
});
var ds = new Ext.data.SimpleStore({....});
var c2 = new Ext.form.ComboBox({
store: ds
.....
});