1. #1
    Sencha User
    Join Date
    Oct 2010
    Location
    Twin Falls, Idaho
    Posts
    9
    Vote Rating
    0
    reuben.olsen is on a distinguished road

      0  

    Default ComboBox - set default value from within Architect.

    ComboBox - set default value from within Architect.


    I've created a ComboBox for which I want to set the default value as the first entry in the store. I've seen code to do this when hand-coding ExtJS but I can't get it to work in Architect. Any advice? Examples?
    Thanks...

  2. #2
    Sencha User
    Join Date
    Nov 2011
    Posts
    18
    Vote Rating
    0
    michabbb is on a distinguished road

      0  

    Default


    hi,

    i did it this way: create a render function for you combo an put

    PHP Code:
    abstractcomponent.setValue(abstractcomponent.getStore().getAt(0).data.id); 
    inside. of course you should have a store for the combo.

  3. #3
    Sencha User
    Join Date
    Oct 2010
    Location
    Twin Falls, Idaho
    Posts
    9
    Vote Rating
    0
    reuben.olsen is on a distinguished road

      0  

    Default


    Thanks for the response but I'm still a bit confused. Here is the code generated for the CB by Architect:

    {
    xtype: 'combobox',
    emptyText: 'Select Questionnaire',
    editable: false,
    displayField: 'SHORT_INS',
    forceSelection: true,
    queryMode: 'local',
    store: 'libraryJson',
    valueField: 'ID_INS',
    valueNotFoundText: '',
    flex: 1
    }

    and the libraryJson store:
    {"total":5,"data":[
    {"ID_INS":"11","SHORT_INS":"CMOTS"},
    {"ID_INS":"12","SHORT_INS":"DAS"},
    {"ID_INS":"13","SHORT_INS":"OQ 45.2"},
    {"ID_INS":"2","SHORT_INS":"Y-OQ 2.01"},
    {"ID_INS":"1","SHORT_INS":"Y-OQ-SR 2.0"}
    ]}

    When the view loads I want the first entry in the store to be selected in the CB.

    Additional help appreciated.
    Reuben

  4. #4
    Sencha User
    Join Date
    Nov 2011
    Posts
    18
    Vote Rating
    0
    michabbb is on a distinguished road

      0  

    Default


    hi,

    i am also new to all the extjs stuff, but i googled and the only simple working solution i found is what i already told you: create a render function for your combo and put the code inside. it will load the first item in your store. all the commands used in my example can be found at the docu.

  5. #5
    Sencha User
    Join Date
    Oct 2010
    Location
    Twin Falls, Idaho
    Posts
    9
    Vote Rating
    0
    reuben.olsen is on a distinguished road

      0  

    Default


    Thanks michabbb - I was able to get this working.

    I ended up attaching the code to the controller used with the CB using the 'render' event. Works great.

    Reuben

  6. #6
    Sencha User
    Join Date
    Oct 2010
    Location
    Twin Falls, Idaho
    Posts
    9
    Vote Rating
    0
    reuben.olsen is on a distinguished road

      0  

    Default


    OK - I thought all was well with this but there is another issue.

    Ever since adding the code to set the default value of the CB I've been getting a console error:

    Cannot read property 'data' of undefined

    It is intermittent but happens more often than not when the app is loaded/reloaded. The code referenced by the error is always the default selection code.

    Here is the code I'm using in a Controller using an onComboboxRender event.

    Code:
    Ext.define('OT.controller.asqChartPanel', {    extend: 'Ext.app.Controller',
         views: [
            'mainDashboardView'
        ],
    
        onComboboxSelect: function(combo, records, options) {
            var store = Ext.data.StoreManager.lookup('avgScoreJson');
            if(combo.id == 'asqChartCB1'){
                var id_ins= records[0].data.ID_INS;
                Ext.apply(store.proxy.extraParams, { "ID_INS": id_ins});
                store.load();
            } else if(combo.id == 'asqChartCB2'){
                var filter = records[0].data.FILTER;
                Ext.apply(store.proxy.extraParams, { "FILTER": filter});
                store.load();
            }
        },
    
        onComboboxRender: function(abstractcomponent, options) {
            if(abstractcomponent.id == 'asqChartCB1') abstractcomponent.setValue(abstractcomponent.getStore().getAt(0).data.ID_INS);
            else if(abstractcomponent.id == 'asqChartCB2') abstractcomponent.setValue(abstractcomponent.getStore().getAt(0).data.FILTER);
        },
    
        init: function() {
            this.control({
                "#asqChartToolbar > combobox": {
                    select: this.onComboboxSelect,
                    render: this.onComboboxRender
                }
            });
    
        }
    
    });
    It appears that the Store has not fully initialized before the CB is rendered - not sure how that is even possible.

    FYI: the store that asqChartCB1 builds from is a remote AJAX store. asqChartCB2 references a local ARRAY store. It is the remote store that seems to cause the error.

    Any ideas?
    Reuben

Thread Participants: 1

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