0

I have a little problem with combobox. I have a combobox Store which is reload using ajax after some event. After that I use myCombo.setValue() to set a default combobox selected field. It works good. Problem is when I click on the combo and Dropdown list is showing. That list automatically hide. But only on the first time, then every thing working good until I reload my form. May I show a part of my code:

store:


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'
        }
    }
});

it is reloading a store:


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; 

Does somebody understand me and could try to help me?

best regards!

Karol Cudzich
  • 61
  • 1
  • 4

2 Answers2

0

load() method is asynchronous. That means you can't assume store is loaded right after you call load(). You need to configure handler for the store load event and continue your logic - setValue(), etc there.

sha
  • 17,824
  • 5
  • 63
  • 98
  • Thanks for you answer, but I know it. I've tried with handlers but it dosn't work correctly.. Data is loaded, I know it, but when I dropdown a list I see it 0.2sec and it hide. It looks correctly. When I dropdown again it working good. – Karol Cudzich Apr 30 '12 at 00:15
  • It's hard to imagine a bug in a such basic functionality for a product that has been used by so many people. I don't see any problems with combos and remote stores anywhere in my projects. Please post more code for your combobox definition and workflow. – sha Apr 30 '12 at 00:41
  • I didn't write that bug is in a library but it is in my code! :) I put more code tomorrow .. I must wait 8 hours before I post again.. :) thanks for trying help! – Karol Cudzich Apr 30 '12 at 01:05
  • It's very unclear what are you trying to do. You have a radio group and on each second change you reload some store. You also have some tree view and on click event you setValue to some combo. But where is the combo and how is it defined? – sha Apr 30 '12 at 13:05
0

I don't think that a bug is in a library, but only in my code!

this is a part when I call a Load store


 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;

                                }
                            }
                    }

and this is listener on tree panel, where I use 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 );
            }
}

after 'itemclick' a 'change' event in radiogroup is fire automatically. It's a part of my code, but that important part.

Karol Cudzich
  • 61
  • 1
  • 4