一.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
紫蝶∏飛揚↗ 阅读(5577)
评论(2) 编辑 收藏 所属分类:
EXTJS