如有这样一个JSON对象:
- {"users":[
- {"id":1,"role":{"id":1,name:"管理员"},"name":"NameA","TrueName":"name1"},
- {"id":1,"role":{"id":1,name:"经理"},"name":"NameB","TrueName":"name2"},
- ]
- }
在页面中,我要在EasyUI的datagrid中显示如下列:
id,role中的name, name则做如下处理:
- <table id="datagrid" class="easyui-datagrid" width="460px"
- url="User!queryAllUser" title="用户表" auto-resize="true" pagination="true"
- fitColumns="true">
- <thead>
- <tr>
- <th field="id" checkbox="true"></th>
- <th field="name">用户名</th>
- <th field="role" formatter="formatRole">角色名</th>
- <th field="TrueName">真实姓名</th>
- </tr>
- </thead>
- </table>
- <script>
- function formatRole(value){
- return value.name;
- };
- </script>