1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    48
    Answers
    1
    Vote Rating
    0
    qt4x11 is on a distinguished road

      0  

    Default Answered: combobox local store and data - set default value

    Answered: combobox local store and data - set default value


    Hi -

    I have a very simple combobox - I'm creating the store and its data locally since the data set is so small.

    Code:
    	items : [{
    		xtype : 'combo',
    		fieldLabel : 'Station Closed Filter',
    		labelAlign : 'left',
    		store : new Ext.data.SimpleStore({
    					data : [[0, 'SHOW OPEN AND CLOSED STATIONS'], [1, 'SHOW OPEN STATIONS'],
    							[2, 'SHOW CLOSED STATIONS']],
    					id : 0,
    					fields : ['value', 'text']
    				}),
    		valueField : 'value',
    		displayField : 'text',
    		triggerAction : 'all',
    		editable : false,
    		name : 'closedStatus',
    		itemId : 'stationStatusReportClosedStatus',
    		flex : 1
    	}],
    -is there a way to set default value to this combo without having to redo how I'm declaring it as an item in a form, and creating the store outside of the combo? Thanks.

  2. You can use the value config to set default value.
    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"}
            //...
        ]
    });
    
    // 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',
        value:'AZ',
        renderTo: Ext.getBody()
    });

  3. #2
    Sencha User
    Join Date
    Apr 2010
    Posts
    29
    Answers
    4
    Vote Rating
    0
    josephkirubakaran is on a distinguished road

      0  

    Default


    You can use the value config to set default value.
    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"}
            //...
        ]
    });
    
    // 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',
        value:'AZ',
        renderTo: Ext.getBody()
    });

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    48
    Answers
    1
    Vote Rating
    0
    qt4x11 is on a distinguished road

      0  

    Default


    Thanks for the simple solution. It's working good

    Code:
    	items : [{
    		xtype : 'combo',
    		fieldLabel : 'Station Closed Filter',
    		labelAlign : 'left',
    		store : new Ext.data.SimpleStore({
    					data : [[0, 'SHOW OPEN AND CLOSED STATIONS'],
    							[1, 'SHOW OPEN STATIONS'],
    							[2, 'SHOW CLOSED STATIONS']],
    					id : 0,
    					fields : ['value', 'text']
    				}),
    		valueField : 'value',
    		value: 0,
    		displayField : 'text',
    		triggerAction : 'all',
    		editable : false,
    		name : 'closedStatus',
    		itemId : 'stationStatusReportClosedStatus',
    		flex : 1,
    		listeners : {
    			'select' : function(combo, record) {
    				// we can get the selected value using getValue()
    				closedStatusSelectedID = this.getValue();
    			}
    		}
    	}],

Thread Participants: 1

Tags for this Thread

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