Javascript 在ExtJS中获取一定值的数据存储

Javascript 在ExtJS中获取一定值的数据存储,javascript,extjs,combobox,extjs4,Javascript,Extjs,Combobox,Extjs4,我是ExtJS新手。我在ExtJS中有一个combobox,我想加载存储的第一条记录作为combobox的默认值。这是我的密码 var cutoff = store_dynamic('nr/getCutOffDate', true); var combo_value = //here i want to store the default value taken in the store xtype: 'combobox', margin: '0 10 0 0', labelWidth: 80

我是ExtJS新手。我在ExtJS中有一个combobox,我想加载存储的第一条记录作为combobox的默认值。这是我的密码

var cutoff = store_dynamic('nr/getCutOffDate', true);
var combo_value = //here i want to store the default value taken in the store

xtype: 'combobox',
margin: '0 10 0 0',
labelWidth: 80,
width: 240,
store: cutoff,
displayField: 'date',
valueField: 'dt_val',
fieldLabel: 'Cut-Off Date',
editable: false,
id: 'cutoffdate',
value: combo_value
这是商店里的数据

{"success":true,"metaData":{"fields":["date","dt_val"]},"data [{"date":"June 30, 2015","dt_val":"6\
/30\/2015"},{"date":"June 15, 2015","dt_val":"6\/15\/2015"}]}

dt_val
是组合框中显示的内容。

一般情况下,这将非常容易

var store = combo.getStore(),
    value = store.getAt(0).get(combo.valueField);
combo.setValue(value);
或者,在您的特殊情况下:

combo_value = cutoff.getAt(0).get('dt_val');
但是我想您的代码可能会出现这样的问题:当您初始化组合框时,存储区中还没有填充数据。您最好在组合的
afterrender
和商店的
load
事件中执行此操作,并在设置组合值之前检查
combo.rendered
store.getCount()>0
是否都是
true