如何 select 来自 Ext JS 网格中组合框的值
How to select a value from combo box in Ext JS Grid
我有一个 EXT JS 网格,其中包含一个带有组合框的列。
我想 select 使用 javascript 此下拉列表中的值,我尝试了下面的代码片段,但没有成功。
var comp = Ext.getCmp('grid-accident-voilation');
comp.store.getAt(0).data['c1'].setValue('1');
[编辑: 浏览器控制台日志]
查询组合框并使用 myComboBox.setValue(1)
。
必须在组合框上调用 setValue 方法。
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.field.ComboBox-method-setValue
组合框需要在商店中的商品上配置一个字段,该字段是每个商品的值。如果您只想 select 第一个可用选项,请从商店中获取第一个项目并在组合框中设置其值。
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));
我有一个 EXT JS 网格,其中包含一个带有组合框的列。
我想 select 使用 javascript 此下拉列表中的值,我尝试了下面的代码片段,但没有成功。
var comp = Ext.getCmp('grid-accident-voilation'); comp.store.getAt(0).data['c1'].setValue('1');
[编辑: 浏览器控制台日志]
查询组合框并使用 myComboBox.setValue(1)
。
必须在组合框上调用 setValue 方法。 http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.field.ComboBox-method-setValue
组合框需要在商店中的商品上配置一个字段,该字段是每个商品的值。如果您只想 select 第一个可用选项,请从商店中获取第一个项目并在组合框中设置其值。
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));