`
tanbamboo
  • 浏览: 19130 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Handling JSON NULL

阅读更多
原文: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;}}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics