一.JS文件
var Employee = Ext.data.Record.create([
{name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
{name: 'occupation'} // This field will use "occupation" as the mapping.
]);
var myReader = new Ext.data.JsonReader({
totalProperty: "results", // The property which contains the total dataset size (optional)記錄總數(shù)(可選)
root: "rows", // The property which contains an Array of row objects 數(shù)組類型的行對(duì)象
id: "id" // The property within each row object that provides an ID for the record (optional) 行對(duì)象里的主鍵(可選)
}, Employee);
二.JSP,PHP,ASP,ASP.NET等文件輸出內(nèi)容
{ 'results': 2, 'rows': [ { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
{ 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
}
三.JsonReader 構(gòu)造函數(shù)
JsonReader(
jsonData : Object
After any data loads, the raw JSON data is available for further custom processing. If no data is loaded or there is a load exception this property will be undefined. 行數(shù)據(jù)
meta : Mixed
This JsonReader's metadata as passed to the constructor, or as passed in the last data packet's MetaData property. 列數(shù)據(jù)
)
樣例:
var record=new Ext.data.Record({}); //必須添加{},且Ext.data.Record.creat({})設(shè)置后. record.set(f.items.items[i].name,f.items.items[i].value) 報(bào)錯(cuò).
record.set(f.items.items[i].name,f.items.items[i].value);
Ext.Ajax.request({
params :record.data ,
url : "author_json1.faces",
waitMsg : '保存中,請(qǐng)稍后...',
success : function(re, v) {
f.ownerCt.close();// 沒(méi)有修改過(guò)則直接退出.
//var json = Ext.util.JSON.decode(v.response.responseText);
//author_store.loadData(json);
// Ext.Msg.alert("success!","add:"+json.author);
// 重新加載author tab內(nèi)容.
// author_store.load({params:{webname:"findall"}});
},
failure : function() {
Ext.Msg.alert("", "failure!");
}
})
posted on 2008-06-04 11:45
紫蝶∏飛揚(yáng)↗ 閱讀(5582)
評(píng)論(2) 編輯 收藏 所屬分類:
EXTJS