Ext combo的数据还原问题

在使用Ext做数据还原的时候,一般的情况还好解决,但是combo如果是采用远程(remote)方式加载,在做数据还原的时候无法还原理想的值,也就是直接选中值,并且hiddenName中是其编号!这中操作如果combo如本地(local)的情况很好处理,只需将其编号传入ext combo会自动查找simpleStore对象中的value值对应的text值,但是远程我使用的是JSONStore在使用本地的思路就行不通了,应该怎么处理这种combo远程恢复数据的情况呢?

应该是默认选中问题吧这样处理

把你的store设置成AutoLoad:true
让后在你store的load事件里面添加这样的语句
combo.setValue(value);

就 ok了。

// JSON [["1", "aaa", false], ["2", "bbb", true], ["3", "ccc", false]]

var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy( {
url: "url"
}),
reader: new Ext.data.ArrayReader({}, [
{name: 'value'},
{name: 'text'},
{name: 'checked'}
])
});
store.load();

var combo = new Ext.form.ComboBox({
width: 150,
fieldLabel: "fieldLabel",
name: "name",
hiddenName: "name",
mode: 'local',
editable: false,
triggerAction: 'all',
store: store,
valueField: 'value',
displayField: 'text'
});

store.on("load", function(store, records, option) {
for(i = 0; i < records.length; i++) {
if(records[i].data.checked == true) {
combo.setValue(records[i].data.value);
}
}
});