ITeye博客

Handling JSON NULL

tanbamboo · 2009-08-05 17:13 · Java · PHP · EXT · json · Markdown

原文:http://extjs.com/forum/showthread.php?t=46336

通过为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;}}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。