Extjs

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
 }

Session setting in EXTJS

We usually play with session and create the session by server side script like PHP. But, how we create session with client side script?

In this case is EXTJS. OK… You can store cookie instead of session for this case.

This is the code;

The first thing you need to do is setProvider and set a variable into it;

Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
Ext.state.Manager.set("varA",varA);

And then to get varA from cookies;

Ext.state.Manager.get("varA")

And if you need to clear that value from cookies

Ext.state.Manager.clear("varA");

That’s it!