1. #1
    Ext User srajakaruna's Avatar
    Join Date
    Apr 2008
    Location
    Sri Lanka
    Posts
    161
    Vote Rating
    0
    srajakaruna is on a distinguished road

      0  

    Default [SOLVED] Combobox FireEvent works incorrectly

    [SOLVED] Combobox FireEvent works incorrectly


    I add hilighted lines if the country is in the session,

    _c.setValue('227'); works fine. I want fire the select event of the combo.

    Its fires up but incorrectly. am i passing the correct values

    Code:
    var _pos = _c.store.find('vl','227');
    _c.fireEvent('select',_c,_c.store.getAt(_pos),_pos)
    Is this method correct ? Please help


    Code:
    {
        xtype		:'combo',
        name		:'pr_country',
        id 			:'pr_countryId',
        hiddenName	:'pr_hidcountry',
        hiddenId 	:'pr_hidcountryId',
        fieldLabel	:'Country',
        store		:new Ext.data.Store({
            proxy:new Ext.data.HttpProxy({url:'get_store.php'}),
            baseParams:{scr:'combo_country'},
            reader:new Ext.data.JsonReader({
                root: 'result',
                totalProperty: 'total',
                successProperty :'success'
            },Ext.data.Record.create([{name:'vl'},{name:'cd'},{name:'txt'}])),
            autoLoad:true,
            listeners:{
                load:function(){
                    var _c = Ext.getCmp('pr_countryId');
                    _c.enable();
                    Ext.get('admin_n3.m1_tab').unmask();
                    _c.setValue('227');
    		var _pos = _c.store.find('vl','227');
    		_c.fireEvent('select',_c,_c.store.getAt(_pos),_pos)
                }
            }
        }),
        mode:'local',
        queryAction: 'all',
        lastQuery: '',
        displayField:'txt',
        valueField:'vl',
        emptyText:'Select a Country...',
        editable:true,
        triggerAction: 'all',
        width		:180,
        maxLength	:240,
        allowBlank	:false,
        forceSelection:true,
        disabled:true,
        typeAhead	:true,
        listeners	:{
            select: function(_cmb, _rcd, _idx){
                alert(_cmb+'  '+_rcd+'  '+_idx);
                Ext.getCmp('pr_destId').store.baseParams.cid = _cmb.getValue();
                var _cp2 = Ext.getCmp('pr_stateId');
                var _cp3 = Ext.getCmp('pr_destId');
                _cp2.reset();
                _cp3.reset();
                _cp2.disable();
                _cp3.disable();
                _cp2.store.clearFilter(true);
                _cp2.store.filterBy(
                    function(_r, _id){
                        return (_r.get('ccd')==_cmb.getValue())? true:false;
                    }
                );
                if (_cp2.store.getRange().length==0){
                    Ext.Msg.show({
                        title	:'Info',
                        msg		:'No States Available for '+_rcd.get('txt')+'',
                        buttons	:Ext.Msg.OK,
                        fn		:function(btn){
                            var _cp3 = Ext.getCmp('pr_destId');
                            _cp3.store.baseParams.cid = _cmb.getValue();
                            _cp3.store.baseParams.sid = 0;
                            _cp3.store.load();
                            Ext.get('admin_n3.m1_tab').mask('Searching Destinations for '+_rcd.get('txt')+'...', 'x-mask-loading');
                        },
                        animEl	:'elId',
                        icon	:Ext.MessageBox.INFO
                    });							
                }else{
                    _cp2.enable();
                    _cp2.setValue('21');
                }
            }
        }
    }
    Manager - Technology
    eMarketingeye Private Limited
    http://www.emarketingeye.com/

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    83
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    I would recommend replacing:
    Code:
    _c.setValue('227');
    var _pos = _c.store.find('vl','227');
    _c.fireEvent('select',_c,_c.store.getAt(_pos),_pos)
    with:
    Code:
    var _rec = _c.findRecord(_c.valueField, '227');
    var _pos = _c.store.indexOf(_rec);
    _c.onSelect(_rec, _pos);

  3. #3
    Ext User srajakaruna's Avatar
    Join Date
    Apr 2008
    Location
    Sri Lanka
    Posts
    161
    Vote Rating
    0
    srajakaruna is on a distinguished road

      0  

    Default


    It works .. great .. Just for clarification,

    According to the Docs there are no findRecord or onSelect methods for combobox .. ?


    Code:
    pr_countryId > combo id
    
    alert(Ext.getCmp('pr_countryId')['findRecord'])
    alert(Ext.getCmp('pr_countryId')['onSelect'])
    when i alert as above I see whats happening inside ...

    .
    Manager - Technology
    eMarketingeye Private Limited
    http://www.emarketingeye.com/

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    83
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    IMHO findRecord should be documented. It returns the first record in the combobox store that has a specific field value (exact match, not the same as using store.find!).

    onSelect is called by onViewClick, which is the dropdown list click handler. So, by calling onSelect you are emulating a dropdown list selection.

  5. #5
    Ext User srajakaruna's Avatar
    Join Date
    Apr 2008
    Location
    Sri Lanka
    Posts
    161
    Vote Rating
    0
    srajakaruna is on a distinguished road

      0  

    Default


    Thanks Condor
    Manager - Technology
    eMarketingeye Private Limited
    http://www.emarketingeye.com/

Thread Participants: 1