Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: How to get combobox display 1st element ?

  1. #11
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,062
    Answers
    3976
    Vote Rating
    1390
      0  

    Default

    if you are doing the getAt right after load, the store isn't loaded at that point. Loading is asynchronous so you have to do this code after the store has loaded

    Code:
    store.on('load', function(store) {
        var rec = store.getAt(0);
        combo.setValue(rec.get(combo.valueField));
    }, store, { single : true });
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  2. #12
    Sencha User
    Join Date
    Sep 2011
    Posts
    36
    Vote Rating
    1
      0  

    Default

    Sorry , may be it becomes ??? , but I got confused :
    I put that code into listeners ( as u can c in code above ) I defined store and created it and panel
    with combo in application. Combo has listeners where I put that code ( or should I put it somewhere else)
    beforerender:function(combo,opts){
    store.on('load', function(store) {
    var rec = store.getAt(0);
    combo.setValue(rec.get(combo.valueField));
    }, store, { single : true });


    }
    }
    .. but still getting nothing

  3. #13
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,062
    Answers
    3976
    Vote Rating
    1390
      0  

    Default

    Ok... you need to stop just copy and pasting code. You need to look at what the code snippets are doing and understand it. In your beforerender listener, is the variable 'store' defined when you do store.on? Or do you need to get the store from the combo parameter in that function?
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

Page 2 of 2 FirstFirst 12

Posting Permissions

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