1.1:jsonstore加载远程数据:
fieldLabel:'证件类型',
id:'idNoType',
name:'dictType',
readOnly:false,
triggerAction:'all',
editable:false,
anchor:'90%',
emptyText:'请选择...',
store:new Ext.data.JsonStore({
url:this.basePath+'BasePackage/common_getSystemDictionaryItem?item_id=20003',
fields:["dictValue","dictValueDesc"],
root:'field1'
}),
valueField:'dictValue',
displayField:'dictValueDesc'
});
远程返回数据格式:json
{"field1":[{"dictValue":"","dictValueDesc",""},{"dictValue":"",""}]}
最好加上editable:false,否则可以自己输入,导致传的数据格式出问题
1.2:jsonstore加载本地数据
fieldLabel:'卡号',
id:'oldCard',
mode:'local',
store:cardStore,
displayField:'card_no'
});
var cardStore = new Ext.data.JsonStore({
fields:['card_no'],
root:'field1'
});
Ext.Ajax.request({url:...,
params:{requesttype:"ajax"},
jsonData:jsonString,
callback:function (options,success,response) {
if (success) {
var jsonObj = Ext.util.JSON.decode(response.responseText);
if (jsonObj.result) {
var retField1 = jsonObj.field1;
if(retField1.length == 0){
...
return;
}else{
cardStore.loadData(jsonObj);
}
} else {
...
}
} else {
...
}
}});
ajax返回的json数据格式:
{"result":true,"field1":[{"card_no":""},{"card_no":""}]}
原文链接:/json/290717.html