1. #1
    Sencha User
    Join Date
    Jun 2011
    Location
    Zurich, Switzerland
    Posts
    11
    Vote Rating
    0
    simiita is on a distinguished road

      0  

    Default dynamic fill select field

    dynamic fill select field


    hello I'm new in Sencha Touch

    I'd like to fill a select field with selectfield.setoptions()

    I got the data from a JSONP Request

    If I put the text from the var directly into the selectfield.setoptions(text); it's working. but I need it dynamicly

    Code:
            Ext.util.JSONP.request({
                url: 'http://localhost:8080/BaReq/', //URL 
                callbackKey: 'callback',
                params: {
                    action: 'getstatements', //Parameter for URL
                    callback: 'true', //also Parameter for URL
                    format: 'json'
                },
                callback: function (result) {
                    var result1 = result.BaReq.categories; //ok!
                   // alert(result1[1].name);
                   //alert(result1.length);
                   
                  
                   var optionArray = '[';
                   for (var i=0; i < result1.length; i++){
                          optionArray = optionArray + '{text: \''+result1[i].name+'\', value: \''+(i+1)+'\'},';
                   }
                   optionArray = optionArray.substr(0,optionArray.length-1);
                   optionArray = optionArray +']';
                   alert(optionArray);                                       
                   //optionArray is correct, if i put the input in the 
                   //setOptions([{text: 't1', value: '1'}, {text: 't2', value '2'}]) method, it's working
                   
                   //on the next line is the error... Uncaught TypeError: Cannot read property 'id' of undefined
                   Ext.getCmp('scannedObject1').setOptions(this.optionArray);             
                   
                   Ext.getCmp('scannedObject1').setValue('1');
                   Ext.getCmp('formresult').doLayout();              
                }
            });

    Thanks for any help

  2. #2
    Sencha User
    Join Date
    Jun 2011
    Posts
    1
    Vote Rating
    0
    hurricane212 is on a distinguished road

      0  

    Default


    hello

    i got exactly the same problem. how i can i fill a selectfield dynamically?


    thanks!

    greetings

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Location
    Zurich, Switzerland
    Posts
    11
    Vote Rating
    0
    simiita is on a distinguished road

      0  

    Default


    I've solved it with a store

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Posts
    7
    Vote Rating
    0
    Magnetica is on a distinguished road

      0  

    Default


    can you post code please?

  5. #5
    Sencha User
    Join Date
    Jun 2011
    Location
    Zurich, Switzerland
    Posts
    11
    Vote Rating
    0
    simiita is on a distinguished road

      0  

    Default


    Sorry for the late reply, I was in holiday.

    I work with a store where all entry are in it. But they have an extra field, where i can put the selection criterion..

    For example male/female


    This listeners is the trigger for changing the variables of the select field:
    Code:
    listeners: {
                    change: function(){
                        
                        //This is the dynamic selectfield 
                        var detailedSelect = MyApp.FormPanel.items.get('detailedRequest');
                        
                        //I remove the old Filter
                        detailedSelect.store.clearFilter(); // remove the previous filter
                        
                        //And i set the new Filter with the active value of another select field
                        detailedSelect.store.filter('cat', Ext.getCmp('scannedObject').getValue());
                        
                        //Here I set a value in the dynamic selectfield, which should be shown.. it's the first entry of the new filter
                        var newSelection = detailedSelect.store.getAt(0);
                        
                        // if not undefined we can set the value to the first record's 
                        if(newSelection){
                            detailedSelect.setValue(newSelection.data.value);
                        } else {
                            detailedSelect.setValue('');
                        }
                    }
                }

    If the description isn't helpful enough i'll try to explain it better..

    Greez

  6. #6
    Sencha User
    Join Date
    Jun 2011
    Posts
    7
    Vote Rating
    0
    Magnetica is on a distinguished road

      0  

    Default


    thanks!
    i'll try your code ASAP

    cheers

Thread Participants: 2

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar