ExtJS - 选择第一个组合框后未填充第二个组合框
我有两个依赖的组合框,在选择第一个组合框中的某些值后,将填充第二个组合框的值。
为此,我在第一个组合框的选择事件中对第二个组合框使用 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
}
也就是说,当我在加载商店和设置值之间编写警报语句时,值会显示在第二个组合框中,但如果我省略此警报,则组合框中不会设置任何值。
我觉得商店可能需要时间来加载,这一次可能是从警报消息停止中获取的。但作为解决方案,我对第二个组合使用了 autoload:true ,这样就不必加载商店,但情况仍然相同 - 该值不会在没有警报的情况下设置。
谁能解释一下这一点。
浏览器 - IE9
ExtJS - 4
提前致谢。
I have two dependent combo-boxes and the value of second one is populated after some value in the first has been selected.
For this, I am using setValue for the second combo-box at the select event of first one.
Below are the two cases of code, here case 1 doesn't work but case 2 works in 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
}
That is, when I write an alert statment between loading of store and setting the value, then the values gets displayed in the second combobox, but if I omit this alert then there is no value set in the combobox.
I felt that probably the store needs time to load and it could be getting this time from the alert message halt. But as a solution for this, I used autoload:true for the second combo, so that the store doesn't have to be loaded but still the case was same - the value was not getting set without alert.
Could anyone please throw some light at this.
Browser - IE9
ExtJS - 4
Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第二个不起作用,因为加载是异步请求,这意味着当您尝试设置值时,商店尚未加载,在它给它足够的时间加载它之前设置警报......一个快速修复是:
The second doesn;t work because the load is an asynchron request meaning that the store is not loaded yet when you trie to set value, setting an alert before it gives it enough tme to load it ... a quick fix would be: