extjs store 复杂json_extjs 2.3 修复 jsonstore 嵌套多级引用数据NULL的BUG
Ext版本:2.3.0
搜索到一篇有用的鏈接是:
我在使用Ext.grid.GridPanel時,用到了多級JSON。
如:
{
"data": [
{
"id" : 1,"amount" : 100,"costumer" : {
"id" : 123,"name" : "Luis Valdés"
}
},{
"id" : 2,"amount" : 100
}
]
}
在定義列時有 {header:'id',dataIndex:'id'},
{header:'amount',dataIndex:'amount'},
{header:'cutomerid','dataIndex:'customer.id'},
{header:'customerName',dataIndex:'customer.name'}
當customer不為空時都正常,空的時候就顯示不出來。解決辦法如下,將Ext.data.JsonReader的getJsonAccessor現有方法:
getJsonAccessor: function(){
var re = /[\[\.]/;
return function(expr) {
try {
return(re.test(expr))
? new Function("obj","return obj." + expr)
: function(obj){
return obj[expr];
};
} catch(e){}
return Ext.emptyFn;
};
}(),
替換為:
getJsonAccessor: function(){
var re = /[\[\.]/;
return function(expr) {
try {
return(re.test(expr))
? new Function("obj","try{return obj." + expr+"}catch(e){}return '';")
: function(obj){
return obj[expr];
};
} catch(e){}
return Ext.emptyFn;
};
}(), 即可解決。
總結
以上是生活随笔為你收集整理的extjs store 复杂json_extjs 2.3 修复 jsonstore 嵌套多级引用数据NULL的BUG的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 444 nginx_nginx 安全问题
- 下一篇: Auto Lisp 标注子样式_FAIR