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

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