1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    32
    Vote Rating
    0
    Santosh Dhumale is on a distinguished road

      0  

    Default Unanswered: add dynamic options to dropdown

    Unanswered: add dynamic options to dropdown


    I tried the linked dynamic dropdown using server side code using JSON and its working fine.


    Now I am converting my existing project in EXT-JS-4.0 and in existing project I did like

    function showitemTypefitting(no){

    var select1 = document.getElementById("itemTypefitting"+no);
    select1.length = 0;
    for(var j=0 ; j < listFittingItemType.length ; j++){

    select1.options[select1.length] = new Option(listFittingItemType[j],j);
    }

    var take = document.getElementById("itemfitting"+no);
    var ele = take.options[take.selectedIndex].text;
    if(ele=="O'LET"){
    ele = "OLET";
    }

    var select = document.getElementById("itemTypefitting"+no);
    for(var i = select.length -1 ; i >=1 ; i--){
    if(select.options[i].text.length >= ele.length ){
    if(ele == "REDUCER" && select.options[i].text.substr(0,5)=="SWAGE" ){

    }else if(select.options[i].text.substr(select.options[i].text.length - ele.length , ele.length) == ele){

    }else if(select.options[i].text == "REDUCING COUPLING" && ele == "REDUCER" ){

    }else if(select.options[i].text == "REDUCING COUPLING" && ele == "COUPLING"){
    select.remove(i);

    }else{
    select.remove(i);
    }
    }else{
    select.remove(i);
    }
    }


    }

    and its working fine.

    Explanation :
    There are two drodown each dropdown data came from an array.
    The above function called onchange event of "itemfitting"+no.


    How to do it in extjs.
    Please help me to change the store of dropdown at client side.

    Thanks in advance.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,085
    Answers
    675
    Vote Rating
    467
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    You can add items to the store by creating a listener in load ..

    Code:
        listeners: {
            load: function() {
    	    this.insert('modelStatus', {
                    id_status  : 0,
                    status_name: '-',
                    id_level: 1
    	    });
            }
        }
    Scott

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    32
    Vote Rating
    0
    Santosh Dhumale is on a distinguished road

      0  

    Default


    load not worked for mw.

    It is not showing any error.

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,085
    Answers
    675
    Vote Rating
    467
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    See if this helps: (not sure what you mean by 'mw')

    Code:
    // The data store containing the list of states
    var states = Ext.create('Ext.data.Store', {
        fields: ['abbr', 'name'],
        data : [
            {"abbr":"AL", "name":"Alabama"},
            {"abbr":"AK", "name":"Alaska"},
            {"abbr":"AZ", "name":"Arizona"}
        ],
        listeners: {
            load: function(store) {
                var newRec = {abbr: 'SS', name: 'SenchaSupport'};
                store.insert(0,newRec);
            }
        }    
    });
    
    // Create the combo box, attached to the states data store
    Ext.create('Ext.form.ComboBox', {
        fieldLabel: 'Choose State',
        store: states,
        queryMode: 'local',
        displayField: 'name',
        valueField: 'abbr',
        renderTo: Ext.getBody()
    });‚Äč
    Scott

  5. #5
    Sencha User
    Join Date
    Aug 2012
    Posts
    32
    Vote Rating
    0
    Santosh Dhumale is on a distinguished road

      0  

    Default


    I dont want to do it on store load, when a single row is rendered that time i have to get values from that row add to it an array and after it next row should be rendred.

Thread Participants: 1