Results 1 to 7 of 7

Thread: help with combo

  1. #1
    Sencha User
    Join Date
    Jul 2009
    Posts
    86

    Default help with combo

    hi all, how can I update the text in a combo for another, I mean, I have 2 combos, and when I click one, the other should change showing the first element automatically without click on the second combo

  2. #2

  3. #3
    Sencha User
    Join Date
    Jul 2009
    Posts
    86

    Default

    hi fangzhouxing, this code is for populate the second combo from on first, but If I want to show the second item of the second combo only when I clicked the first combo, how do I do?

  4. #4
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    707

    Default

    Did you try using the combo's select() function? See ComboBox API

  5. #5
    Sencha User
    Join Date
    Jul 2009
    Posts
    86

    Default

    I use this

    Code:
        var abc = function(index){
            sp_dsTabla.on('load', function() {
                alert(index);
                sp_CmbTabla.setValue(sp_dsTabla.getAt(index).data['nameForUser']);
            });
        };
    
        sp_CmbAlarm.on("select", function(){
            index = sp_CmbAlarm.selectedIndex;
            sp_dsTabla.removeAll();
            sp_GridAlarmLoad();
            var modelDest = Ext.getCmp('sp_CmbTabla');
            modelDest.store.reload({params: { alarmId: sp_CmbAlarm.getValue(), Action: 'C' }});
        });
    the index extist but not load the combo ; i have error in this line
    "sp_CmbTabla.setValue(sp_dsTabla.getAt(index).data['nameForUser']);"

  6. #6
    Sencha User
    Join Date
    Jul 2009
    Posts
    86

    Default

    I have this

    this is my first combo
    Code:
        var sp_CmbAlarm =new Ext.form.ComboBox({
            id : 'sp_CmbAlarm',
            name :'sp_CmbAlarm',
            typeAhead : true,
            triggerAction : 'all',
            lazyRender : true,
            store : sp_dsAlarm,
            displayField : 'Description',
            valueField : 'AlarmId',
            forceSelection : false,
            disabled : false,
            emptyText : '',
            resizable : false,
            editable : true,
            mode : 'local',
            loadingText : 'Loading...',
            fieldLabel : 'Alarma',
            width : 400
        });
    this is the select function on the first combo
    Code:
        sp_CmbAlarm.on("select", function(){
            alert(sp_CmbAlarm.getValue());
            sp_dsTabla.removeAll();
            sp_dsTabla.reload({params:{alarmId: sp_CmbAlarm.getValue(), Action: 'C'}});
            sp_GridAlarmLoad();
        });
    why I use "reload"? because I want to refresh the text in the second combo, showing the first item

    this is my second combo
    Code:
        var sp_CmbTabla =new Ext.form.ComboBox({
            id : 'sp_CmbTabla',
            name :'sp_CmbTabla',
            hiddenName : 'Tabla',
            typeAhead : true,
            triggerAction : 'all',
            lazyRender : true,
            store : sp_dsTabla,
            displayField : 'nameForUser',
            valueField : 'tableId',
            forceSelection : true,
            emptyText : '',
            resizable : false,
            editable : false,
            mode : 'local',
            loadingText : 'Loading...',
            fieldLabel : 'Tabla',
            width : 160,
            maxHeight : 200
        });

  7. #7
    Sencha User
    Join Date
    Jul 2009
    Posts
    86

    Default

    well I try with this:

    this is my first combo
    Code:
        sp_CmbAlarm =new Ext.form.ComboBox({
            id : 'sp_CmbAlarm',
            name :'sp_CmbAlarm',
            typeAhead : true,
            triggerAction : 'all',
            lazyRender : true,
            store : sp_dsAlarm,
            displayField : 'Description',
            valueField : 'AlarmId',
            forceSelection : false,
            disabled : false,
            emptyText : '',
            resizable : false,
            editable : true,
            mode : 'local',
            loadingText : 'Loading...',
            fieldLabel : 'Alarma',
            width : 400
        });
    here, when the store "sp_dsTabla" reload , only have one item, and this item I want to visualize in the second combo automatically, that's the reason I use reload, but not works, by now I need to click the second combo to show the unique item and select it
    Code:
        sp_CmbAlarm.on("select", function(){
            index = sp_CmbAlarm.selectedIndex;
            sp_dsTabla.removeAll();
            sp_dsTabla.reload({params:{alarmId: sp_CmbAlarm.getValue(), Action: 'C'}});
            sp_GridAlarmLoad();
            sp_btnAlarm.setDisabled(false);
        });
    this is my second combo
    Code:
        sp_CmbTabla =new Ext.form.ComboBox({
            id : 'sp_CmbTabla',
            name :'sp_CmbTabla',
            hiddenName : 'Tabla',
            typeAhead : true,
            triggerAction : 'all',
            lazyRender : true,
            store : sp_dsTabla,
            displayField : 'nameForUser',
            valueField : 'tableId',
            forceSelection : true,
            emptyText : '',
            resizable : false,
            editable : false,
            mode : 'local',
            loadingText : 'Loading...',
            fieldLabel : 'Tabla',
            width : 160,
            maxHeight : 200
        });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •