原文:[url]http://extjs.com/forum/showthread.php?t=46336[/url]
通过为Ext.data.JsonReader的字段加上convert来处理条件映射的问题。
示例如下:
修改Owerne.Name的Mapping方式为下面:
通过为Ext.data.JsonReader的字段加上convert来处理条件映射的问题。
示例如下:
{"licences":[{"Id":2,"LicenseKey":"123456","Point":null,"Owner":{"Id":1,"Name":"Witbit"}, "Mac":null,"Active":false},
{"Id":3,"LicenseKey":"789013","Point":null,"Owner":null, "Mac":null,"Active":false}]} this.DS = new Ext.data.Store(
{
reader: new Ext.data.JsonReader(
{
root: "licences",
fields: [ "Id", "LicenseKey", {name:"Owner_Name", mapping:"Owner.Name"}, "Point", "Mac", "Active" ]
})
}); 修改Owerne.Name的Mapping方式为下面:
{name:"Owner_Name", mapping:"Owner", convert: function(v) {return v ? v.Name : null;}}
本文介绍如何使用ExtJS中的JsonReader组件通过添加convert函数实现对JSON数据中特定字段的条件映射,以处理复杂的数据转换需求。
1596

被折叠的 条评论
为什么被折叠?



