【问题标题】:little bug in Combobox in extjs 4.0.7 after store load存储加载后 extjs 4.0.7 中 Combobox 中的小错误
【发布时间】:2012-04-29 23:17:20
【问题描述】:

我对组合框有一点问题。 我有一个组合框商店,它在某些事件后使用 ajax 重新加载。之后,我使用 myCombo.setValue() 设置默认组合框选定字段。它运作良好。问题是当我单击组合并显示下拉列表时。该列表会自动隐藏。但仅在第一次,然后一切正常,直到我重新加载我的表格。 我可以展示我的部分代码吗:

商店:


var ParentsStore =   Ext.create('Ext.data.Store', { 
    autoLoad: false,
    fields: ['id', 'name'],
    proxy: {
        type: 'ajax',
        url: 'index.php?aid=parents_combostore',
        reader: {
            type: 'xml',
            record: 'item',
            idProperty: 'ASIN',
            totalRecords: '@total'
        }
    }
});

它正在重新加载商店:


Ext.getCmp('userParent_combo_id').clearValue();

       ParentsStore.getProxy().extraParams = 
       {
                 typ :typ['usrtyp_id']
       };
            Ext.getCmp('userParent_combo_id').store.load();
            Ext.getCmp('userParent_combo_id').lastQuery = null; 

有人了解我并可以尝试帮助我吗?

最好的问候!

【问题讨论】:

    标签: extjs combobox drop-down-menu setvalue


    【解决方案1】:

    load() 方法是异步的。这意味着您不能假设商店在您调用load() 后立即加载。您需要为商店加载事件配置处理程序并继续您的逻辑 - setValue() 等。

    【讨论】:

    • 谢谢你的回答,但我知道。我已经尝试过处理程序,但它不能正常工作。数据已加载,我知道,但是当我下拉列表时,我看到它 0.2 秒并且它隐藏了。它看起来正确。当我再次下拉时,它运行良好。
    • 很难想象这么多人使用的产品的基本功能中存在错误。在我的项目中的任何地方,我都没有看到组合和远程商店有任何问题。请为您的组合框定义和工作流程发布更多代码。
    • 我没有写那个错误在库中,但它在我的代码中! :) 明天我会添加更多代码.. 我必须等待 8 小时才能再次发布.. :) 感谢您的帮助!
    • 目前还不清楚您要做什么。您有一个广播组,并且在每一秒更改时您都会重新加载一些商店。您还有一些树形视图,并在单击事件时将值设置为某些组合。但是组合在哪里以及它是如何定义的?
    【解决方案2】:

    我不认为错误存在于库中,而仅存在于我的代码中!

    这是我调用加载存储时的一部分

    
     xtype: 'radiogroup',
                        columns: 1,
                        fieldLabel: 'typ',
                        id: 'typ_radio_id',
    
                        items: [
                            usrtyp_item
                        ],
                        listeners: {
                                change: {
                                    fn: function(field,new_value,old_value,options)
                                    {
                                            typ=Ext.getCmp('typ_radio_id').getValue();
    
                                            if(second_change)
                                            {
                                                Ext.getCmp('userParent_combo_id').clearValue();
    
    
                                                ParentsStore.getProxy().extraParams = {
                                                    typ :typ['usrtyp_id']
                                                };
                                                Ext.getCmp('userParent_combo_id').store.load();
                                                Ext.getCmp('userParent_combo_id').lastQuery = null; 
    
                                                second_change=0;
                                            }
                                            else second_change=1;
    
                                    }
                                }
                        }
    

    这是树形面板上的侦听器,我在其中使用 setValue

    
    listeners: {
                'itemclick': function(this_el,record,item,index,e,eOpts)
                {
                        var user_info = getUserById( record.get('id') );    
    
    
                            parent_id=user_info['parent_id'];
                            second_change=0;
    
                            Ext.getCmp('userParent_combo_id').setValue( parent_id );
                }
    }
    

    在“itemclick”之后,radiogroup 中的“更改”事件会自动触发。这是我的代码的一部分,但也是很重要的部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-29
      • 1970-01-01
      • 1970-01-01
      • 2013-05-28
      • 1970-01-01
      相关资源
      最近更新 更多