Results 1 to 3 of 3

Thread: Default selection on a combo box

  1. #1
    Ext User
    Join Date
    Feb 2010
    Posts
    6
    Vote Rating
    0
      0  

    Default Default selection on a combo box

    This should be a very simple but I could not figure it out. I have defined a combobox and would like this combobox to display a default selection. The data store is defined as follow:

    createStore: function () {
    var countryStore = new Ext.data.SimpleStore( {
    fields: ['country', 'abbr'],
    data: [ ['United States', 'US'], ['Canada', 'CA'] ]
    });
    return countryStore;
    }

    I tried calling setValue('US') and setValue('United States') but they both failed to work. I am wondering if this is even the right way to do it. Any suggestions?

  2. #2
    Sencha User bclinton's Avatar
    Join Date
    Nov 2007
    Posts
    305
    Vote Rating
    11
      0  

    Default

    It doesn't have anything to do with your issue, but SimpleStore is now known as ArrayStore so you should probably get used to writing that

    What are you calling setValue on, the Store or the ComboBox? You should be calling it on the ComboBox. Also, when are you calling it? before or after the store loads?

  3. #3
    Ext User
    Join Date
    Feb 2010
    Posts
    6
    Vote Rating
    0
      0  

    Default

    I set the value of the combobox, after the store is set as below. In both cases, getValue return what I was setting the combobox with. What am I doing wrong?

    Ext.apply(this, {
    store: this.createStore()
    });
    alert('current value is (' + this.getValue() + ')');
    // test1
    // Ext.apply(this, {
    // value: ['US']
    // });

    //test2
    //this.setValue('United States');

    alert('new value is (' + this.getValue() + ')');

Posting Permissions

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