1. #1
    Sencha User
    Join Date
    Jun 2008
    Posts
    69
    Vote Rating
    0
    pouniok is on a distinguished road

      0  

    Default [Solved] Load a ComboBox, Load a Datastore and set the combobox value with ds data

    [Solved] Load a ComboBox, Load a Datastore and set the combobox value with ds data


    Hi,

    My title isn't very explicit, what I'm looking for is the best way to load a datastore, load a combobox, and when both are loaded, set the combobox value with a datastore data.


    I think it's something that people should do everyday here, and my way works, but has a little bug.


    What I do is like that :

    - I create a function for the datastore event "load"
    - In that function, I put a combobox datastore listener on the "load" event too
    - In the combobox function, I set the value with the datastore value (I thought both ds would be loaded here)
    - I load the combobox in the datastore on load event

    Looks like this :
    Code:
    var datastore = new Ext.data.Store({
         proxy: new Ext.data.HttpProxy({url: some_url }),
         reader: new Ext.data.JsonReader({}, [fields_here]),
         remoteSort: true
    });
    
    datastore.on('load', function(store){
         var data = datastore.getAt(0).data;
    
         cboDs.on('load', function(){
    	cbo.setValue(data.my_value);
         });
         cboDs.load();
    });

    When I'm opening tabs with this code, some times everything works, but other times I juste got the Id's in my combo box values because it hasn't been loaded.



    If someone knows a way to do that better, I would be glad



    Thank you,
    pouniok.

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


    There are several solutions:
    1. Delay the setValue until the store is loaded (example here).
    2. Set both the value and the display text at the same time (example here).
    3. Load the data for both stores in one request (preferred method, because it only takes one request).

  3. #3
    Sencha User
    Join Date
    Jun 2008
    Posts
    69
    Vote Rating
    0
    pouniok is on a distinguished road

      0  

    Default


    Thank you for your answer.

    The third choice may be the best, but I think it's not for me since I could have like 10 combobox to load in my datastore.

    I'll try one of the 2 above


    Pouniok.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi