【问题标题】:ExtJS - second combo-box not getting populated after choosing first oneExtJS - 选择第一个组合框后没有填充第二个组合框
【发布时间】:2011-09-02 09:10:25
【问题描述】:

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

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

提前致谢。

【问题讨论】:

    标签: extjs combobox load internet-explorer-9 loading


    【解决方案1】:

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

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

    【讨论】:

    • 我在考虑同样的问题,但是当我设置 autoload:true (并删除 select 上的 store 加载)时,这也不起作用。这背后的原因可能是什么?与 autoLoad:true 的情况一样,第二个组合框的商店已经存在。
    • 只是为了确认nscrob提供的解决方案有效。希望这对某人有用。但是自动加载的东西仍然模棱两可。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多