jquery easyui datagrid 嵌套对象绑定
jquery easyui datagrid 嵌套对象绑定,网上很多资料说是easyui本身不支持嵌套对象绑定,但很多时候我们恰恰需要这种嵌套对象绑定,而实际上是可以实现且支持的,只需调用formatter函数就可以实现。
json 格式:
{ "total":239, "rows":[ {"code":"001","user":{"id":1,"name":"name1"},"addr":"Address 11","col4":"col4 data"}, {"code":"002","user":{"id":1,"name":"name1"},"addr":"Address 13","col4":"col4 data"}, {"code":"003","user":{"id":1,"name":"name1"},"addr":"Address 87","col4":"col4 data"}, {"code":"004","user":{"id":1,"name":"name1"},"addr":"Address 63","col4":"col4 data"}, {"code":"005","user":{"id":1,"name":"name1"},"addr":"Address 45","col4":"col4 data"}, {"code":"006","user":{"id":1,"name":"name1"},"addr":"Address 16","col4":"col4 data"}, {"code":"007","user":{"id":1,"name":"name1"},"addr":"Address 27","col4":"col4 data"}, {"code":"008","user":{"id":1,"name":"name1"},"addr":"Address 81","col4":"col4 data"}, {"code":"009","user":{"id":1,"name":"name1"},"addr":"Address 69","col4":"col4 data"}, {"code":"010","user":{"id":1,"name":"name1"},"addr":"Address 78","col4":"col4 data"} ] }
js代码:
{field:'Id',title:'Id',width:120, formatter:function(value,rec){ return rec.user.id; } }, {field:'Name',title:'Name',width:120, formatter:function(value,rec){ return rec.user.name; } }
注意,field命名是不能重复的,这样就可以实现嵌套对象绑定了
相关推荐
89427412 2020-02-13
morexyoung 2019-12-20
EdwardSiCong 2015-04-11
ningwentao 2015-10-21
zderam的私人 2019-09-02
shanhuijava 2016-08-17
wndong 2016-03-04
AngelicaA 2015-12-22
xiaobozhu 2015-10-27
yypiao 2015-10-21
小策一喋 2015-09-17
小仙儿 2015-06-15
huzai 2015-06-03
huzai 2015-04-22
zhangmingming 2015-03-11
大数据实战派 2015-02-04
葉無聞 2015-01-01
sunnylinner 2014-12-19