EasyUI DataGrid绑定嵌套的json数据

现有json数据如下:

{"total":2,"rows":
[{"BarrackGUID":"dc1be891-4489-4eb8-bb1d-ba1debd59b07","BarrackName":"屋舍一","BarrackNumber":"0001","BarrackArea":"100平米","Barrackcapacity":"20","BarrackPrice    ":"3000","Barrackbirth":"2010年9月",
    "company":{
            "CompanyGUID":"aaa",
            "CompanyName":"sdsdsdsd",
            "CompanyCode":null,
            "CompanyAddress":null
            }},
{"BarrackGUID":"1d90143e-0434-4801-8192-923a9dfb06b6","BarrackName":"屋舍二","BarrackNumber":"0002","BarrackArea":"100平米","Barrackcapacity":"20","BarrackPrice":"3000","Barrackbirth":"2010年9月",
    "company":null
    }]}

可以看出在界面显示中希望显示 company.CompanyName, 绑定方法为:

html:

 <th data-options="field:‘rows.company.CompanyName‘,formatter:companyName,width:60,align:‘center‘">公司名称</th>

添加javasicript代码:

function companyName(value, rec) { return rec.company != null ? rec.company.CompanyName : ""; }

 easyui文档中如下:

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。