我有两个相关的组合框,并且在第一个选择了一些值之后填充了第二个的值。
为此,我在第一个选择事件的第二个组合框中使用setValue。
以下是两种代码案例,此处案例1不起作用,但案例2适用于IE9:
Case1: This doesn't work
select:function(combo, record){
Ext.getCmp('voyageMonitoritngVesselCode').store.load();//Loading the store of second combobox
Ext.getCmp('voyageMonitoritngVesselCode').setValue(record[0].data.vslCd);//Setting the value in the second combo-box
}
Case2: This works
select:function(combo, record){
Ext.getCmp('voyageMonitoritngVesselCode').store.load();//Loading the store of second combobox
alert(record[0].data.vslCd);//The only difference in both cases is this line
Ext.getCmp('voyageMonitoritngVesselCode').setValue(record[0].data.vslCd);//Setting the value in the second combo-box
}
也就是说,当我在加载商店和设置值之间写一个警告声明时,这些值会显示在第二个组合框中,但是如果我省略此警告,那么组合框中没有设置值。
我觉得商店可能需要加载时间,这可能是从警报消息停止的时间。但作为解决方案,我使用自动加载:对于第二个组合使用true,这样就不必加载商店了但情况仍然相同 - 没有警报就没有设置值。
有人可以对此提出一些看法。
浏览器 - IE9
ExtJS - 4
先谢谢。
答案 0 :(得分:0)
第二个不起作用,因为加载是一个异步请求,这意味着当你试图设置值,设置一个警报然后给它足够的时间来加载它时,商店还没有被加载...快速修复会是:
var combo = Ext.getCmp('voyageMonitoritngVesselCode');
combo.store.load({
callback:function(r, options, success) {
combo.setValue(record[0].data.vslCd);
}
});