1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    9
    Vote Rating
    0
    oneofthelions is on a distinguished road

      0  

    Default Default value of combobox

    Default value of combobox


    I have local var (Array list) which has three key, value pairs.

    I want the second value to be displayed in the combo box and its key as default.

    Code:
    Ext.onReady(function(){
    
    var group = [['brand', 'Product'],['site', 'Location'],['environment', 'Environment']];
        Ext.QuickTips.init();
    
        var store = new Ext.data.ArrayStore({
            fields: ['abbr', 'group'],
            data : group
        });
        var combo = new Ext.form.ComboBox({
            store: store,
            displayField:'group',
            typeAhead: true,
            mode: 'local',
            forceSelection: true,
            triggerAction: 'all',
            emptyText:'Location', //So the 'Location' which is second value is to be displayed. And its key 'site' 
            selectOnFocus:true,   
            applyTo: 'local-states'
        });
        combo.selectByValue('site', true); 
    });

  2. #2
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750
    Vote Rating
    9
    fay will become famous soon enough fay will become famous soon enough

      0  

    Default


    Add a valueField config param?

    var combo = new Ext.form.ComboBox({
    //... As before
    valueField: 'abbr'
    });
    combo.selectByValue('site', true);

  3. #3
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    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


    Yes, you should specify valueField:'abbr', but also replace emptyText:'Location' with value:'site'.

Similar Threads

  1. How to set a default value for a comboBox ?
    By rvillane in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 7 Oct 2008, 12:39 PM
  2. [Fix] Combobox Default Value
    By kilrae in forum Ext 1.x: Bugs
    Replies: 3
    Last Post: 29 Sep 2008, 11:28 PM
  3. Combobox with default value
    By bowa in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 28 Feb 2008, 4:04 PM
  4. Combobox - default value
    By mnugter in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 12 Mar 2007, 11:56 PM

Thread Participants: 2

Tags for this Thread