一.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)記錄總數(可選)
root: "rows", // The property which contains an Array of row objects 數組類型的行對象
id: "id" // The property within each row object that provides an ID for the record (optional) 行對象里的主鍵(可選)
}, Employee);
二.JSP,PHP,ASP,ASP.NET等文件輸出內容
{ 'results': 2, 'rows': [ { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
{ 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
}
三.JsonReader 構造函數
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. 行數據
meta : Mixed
This JsonReader's metadata as passed to the constructor, or as passed in the last data packet's MetaData property. 列數據
)
樣例:
var record=new Ext.data.Record({}); //必須添加{},且Ext.data.Record.creat({})設置后. record.set(f.items.items[i].name,f.items.items[i].value) 報錯.
record.set(f.items.items[i].name,f.items.items[i].value);
Ext.Ajax.request({
params :record.data ,
url : "author_json1.faces",
waitMsg : '保存中,請稍后...',
success : function(re, v) {
f.ownerCt.close();// 沒有修改過則直接退出.
//var json = Ext.util.JSON.decode(v.response.responseText);
//author_store.loadData(json);
// Ext.Msg.alert("success!","add:"+json.author);
// 重新加載author tab內容.
// author_store.load({params:{webname:"findall"}});
},
failure : function() {
Ext.Msg.alert("", "failure!");
}
})
posted on 2008-06-04 11:45
紫蝶∏飛揚↗ 閱讀(5582)
評論(2) 編輯 收藏 所屬分類:
EXTJS