Showing posts with label ExtJs ComboBox Listener. Show all posts
Showing posts with label ExtJs ComboBox Listener. Show all posts

Thursday, November 29, 2012

ExtJS ComboBox with local store and change action listener.

new Ext.form.ComboBox({
    fieldLabel: '',
    id: 'searchtypeforcontacts',
    name: 'searchtype',
    x:200,
    labelSeparator :'',
    editable: false,
    store: new Ext.data.SimpleStore({
        fields: ['id', 'header'],
        data: [
            ['id', 'Contact Id'],
            ['first_name', 'Given Name'],
            ['email', 'Email'],
            ['country', 'Country'],
            ['state', 'State'],
            ['suburb_city', 'Suburb/City'],
            ['post_zip_code', 'Post/Zip Code']
        ]
    }),
    displayField: 'header',
    valueField: 'id',
    emptyText:'Search Contacts',
    typeAhead: true,
    mode: 'local',
    anchor: '40%',
    triggerAction: 'all',
    allowBlank: false,
    selectOnFocus: true,
    blankText: 'Select search type',
    listeners:{
        'select':function() {
            if (this.value == 'status') {
                //statusCombo.show();
                searchText.hide();
                $(".customerSearch").css({'margin-left':'210px','width':'auto'});
            } else {
                //statusCombo.hide();
                searchText.show();
                $(".customerSearch").removeAttr("style").css("width:auto;");
            }
        }
    }
})