关于EasyUI Datagrid JSON对象内嵌对象的取值问题

如有这样一个JSON对象:

  1. {"users":[  
  2.         {"id":1,"role":{"id":1,name:"管理员"},"name":"NameA","TrueName":"name1"},  
  3.         {"id":1,"role":{"id":1,name:"经理"},"name":"NameB","TrueName":"name2"},  
  4.     ]  
  5. }  
在页面中,我要在EasyUI的datagrid中显示如下列:
id,role中的name, name则做如下处理:


  1. <table id="datagrid" class="easyui-datagrid" width="460px"  
  2. url="User!queryAllUser" title="用户表" auto-resize="true" pagination="true"  
  3. fitColumns="true">  
  4.     <thead>  
  5.         <tr>  
  6. <th field="id" checkbox="true"></th>  
  7. <th field="name">用户名</th>  
  8. <th field="role" formatter="formatRole">角色名</th>  
  9. <th field="TrueName">真实姓名</th>  
  10.         </tr>  
  11.     </thead>  
  12. </table>  
  13. <script>  
  14.     function formatRole(value){  
  15.         return value.name;  
  16.     };  
  17. </script>  

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值