2
votes

I have an EXT JS grid which contains a column having a combobox.

enter image description here

I want to select a value in this dropdown using javascript, I tried below snippet but it didn't work.

var comp = Ext.getCmp('grid-accident-voilation'); comp.store.getAt(0).data['c1'].setValue('1');

[EDIT : Browser Console Log ]

enter image description here

2

2 Answers

2
votes

The setValue method must be called on the combobox. http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.field.ComboBox-method-setValue

The combobox is required to be configured with a field on the items in the store that are each item's value. If you simply want to select the first available option, get the first item from the store and set its value on the combobox.

var combobox = Ext.getCmp('grid-accident-voilation');
var firstItem = combobox.getStore().getAt(0);
// Optionally, get the value field programmatically.
var valueField = combobox.getInitialConfig('valueField');
combobox.setValue(firstItem.get(valueField));
1
votes

Query for the combobox and use myComboBox.setValue(1).

refer:"ComboBox-method-setValue"