extjs - How to set a default value for combo box -
i have combo box has few static(hard coded) values displayed inside grid.
by default should show first value in combo box. tried few things not work. create staticcombobox first ,
var staticcombobox = ext.extend(ext.form.combobox, { mode: 'local', triggeraction: 'all', editable: false, valuefield: 'value', displayfield: 'label', data: [], initcomponent: function() { this.store = new ext.data.arraystore({ fields: ['value', 'label'], data: this.data }); staticcombobox.superclass.initcomponent.call(this); } }); var cm = new ext.grid.columnmodel([ { id:'language', header: "language", dataindex: 'language', width: 235, menudisabled: true, editor: new staticcombobox({ name: 'reasons', data: [ [0, 'reason 1'], [1, 'second reason'], [2, 'something else'] ] }), listeners: { load: function () { //set combobox value here var combo = ext.getcmp('language'); combo.setvalue("1"); } } } ]);
it unlikely load event cause store filled. try listen render or else.
here working example: http://jsfiddle.net/4baem/3/
use ext.data.store , data has array of records:
new staticcombobox({ name: 'reasons', data: [{value: 0, label: 'reason1'}, {value: 1, label: 'reason2'}] });
Comments
Post a Comment