Hybrid View

  1. #1
    Ext User
    Join Date
    Jun 2007
    Posts
    11
    Vote Rating
    0
    kilrae is on a distinguished road

      0  

    Default [Fix] Combobox Default Value

    [Fix] Combobox Default Value


    We're all familiar (I think) with the problem that values are set on comboboxes before the store loads meaning that you end up with the value displayed in the box instead of the text you want. The solution is to call setValue after the store loads. But, of course, that isn't always appropriate. You might want to use the 'value' config, or call setValues when your Dialog loads or something of that sort.

    If ComboBox.js were modified to add an onLoad event to the store when the combobox is constructed, then this would solve the problem. Something to the effect of:

    Code:
    this.store.on('load',this.onLoad,this);
    ....
    onLoad: function() {
     this.setValue(this.getValue());
    }

  2. #2
    Sencha Premium Member andrei.neculau's Avatar
    Join Date
    Jul 2007
    Location
    Sweden
    Posts
    197
    Vote Rating
    0
    andrei.neculau is on a distinguished road

      0  

    Default


    do combo.setValue(fieldValue), and then combo.setRawValue(displayValue)

    the second call will keep the hiddenField's value intact

  3. #3
    Sencha User bclinton's Avatar
    Join Date
    Nov 2007
    Posts
    274
    Vote Rating
    6
    bclinton will become famous soon enough

      0  

    Default


    What if you don't know the display value?

  4. #4
    Ext User mdelanno's Avatar
    Join Date
    Mar 2007
    Location
    France
    Posts
    71
    Vote Rating
    0
    mdelanno is on a distinguished road

      0  

    Default


    Quote Originally Posted by kilrae View Post
    Code:
    this.store.on('load',this.onLoad,this);
    ....
    onLoad: function() {
     this.setValue(this.getValue());
    }
    This method doesn't work if pageSize is set on the combo (The record is not inevitably on the first page).