Month: May 2014

Extjs Static Combobox

This snippet show you a static combo

{
    xtype:'combo',
    fieldLabel:'Field Label',
    name:'theName',
    queryMode:'local',
    store:['1','2'],
    displayField:'Display Field',
    autoSelect:true,
    forceSelection:true
 }

Another alternative (1):

// The data store containing the list of statesvar 
pilihan = Ext.create('Ext.data.Store', {
    fields:['display','value'],
    data :[{"display":"Ya","value":"1"},
        {"display":"Tidak","value":"0"}]
    });

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox',{ 
    fieldLabel:'Pilih', 
    store: pilihan, 
    queryMode:'local', 
    displayField:'display',
    valueField:'value', 
    renderTo:Ext.getBody()
});
 

Another alternative (2):

{
    xtype:'combo',
    fieldLabel:'Main',
    name:'main',
    queryMode:'local',
    anchor: '100%',
    store: Ext.create('Ext.data.Store', {
        fields: ['value', 'display'],
        data: [
            {
                "display": "Ya",
                "value": 1
            },
            {
                "display": "Tidak",
                "value": 0
            }
        ]
    }),
    displayField:'display',
    valueField: 'value',
    autoSelect:true,
    forceSelection:true
 }