ExtJS - 选择第一个组合框后未填充第二个组合框

发布于 2024-12-02 12:23:49 字数 1089 浏览 2 评论 0原文

我有两个依赖的组合框,在选择第一个组合框中的某些值后,将填充第二个组合框的值。

为此,我在第一个组合框的选择事件中对第二个组合框使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半世蒼涼 2024-12-09 12:23:49

第二个不起作用,因为加载是异步请求,这意味着当您尝试设置值时,商店尚未加载,在它给它足够的时间加载它之前设置警报......一个快速修复是:

var combo = Ext.getCmp('voyageMonitoritngVesselCode');
combo.store.load({
                callback:function(r, options, success) {
                    combo.setValue(record[0].data.vslCd);
                }
            });

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:

var combo = Ext.getCmp('voyageMonitoritngVesselCode');
combo.store.load({
                callback:function(r, options, success) {
                    combo.setValue(record[0].data.vslCd);
                }
            });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文