EasyUI Datagrid JSON对象内嵌对象的取值问题
2016-04-04 16:03
543 查看
如有这样一个JSON对象:
在页面中,我要在EasyUI的datagrid中显示如下列:
id,category中的name,name
则做如下处理:
view
source
print?
1 | { "goods" :[ |
2 | { "id" :1, "category" :{ "id" :1,name: "category1" }, "name" : "NameA" , "shelfLife" :12}, |
3 | { "id" :1, "category" :{ "id" :1,name: "category1" }, "name" : "NameB" , "shelfLife" :12}, |
4 | ] |
5 | } |
id,category中的name,name
则做如下处理:
view
source
print?
01 | < table id = "datagrid" class = "easyui-datagrid" width = "460px" |
02 | url = "goodsList" title = "商品表" auto-resize = "true" pagination = "true" |
03 | fitColumns = "true" > |
04 | < thead > |
05 | < tr > |
06 | < th field = "id" checkbox = "true" ></ th > |
07 | < th field = "name" >商品名称</ th > |
08 | < th field = "category" formatter = "formatCategory" >商品类别</ th > |
09 | < th field = "shelfLife" formatter = "formatShelfLife" >保质期</ th > |
10 | </ tr > |
11 | </ thead > |
12 | </ table > |
13 |
14 | < script > |
15 | function formatCategory(value){ |
16 | return value.name; |
17 | }; |
18 | function formatShelfLife (value){ |
19 | return value + " 月"; |
20 | }; |
21 | </ script > |
相关文章推荐
- easyui------显示隐藏列功能
- 如何使用jquery easyui创建标签组件
- Flex4 DataGrid中嵌入RadioButton实现思路及代码
- datagrid不可编辑行有关问题的控制方法
- jQuery寻找n以内完全数的方法
- C#实现改变DataGrid某一行和单元格颜色的方法
- 推荐10个2014年最佳的jQuery视频插件
- C#设置WinForm中DataGrid列的方法(列宽/列标题等)
- jquery+CSS3实现淘宝移动网页菜单效果
- 采用easyui tree编写简单角色权限代码的方法
- jQuery实现本地预览上传图片功能
- jquery实现触发时更新下拉列表内容的方法
- 基于jquery中children()与find()的区别介绍
- 了解jQuery技巧来提高你的代码(个人觉得那个jquery的手册很不错)
- 轻松学习jQuery插件EasyUI EasyUI实现拖动基本操作
- Flex 自定义DataGrid实现根据条目某一属性值改变背景颜色
- 基于jQuery实现网页打印功能
- 在IE 浏览器中使用 jquery的fadeIn() 效果 英文字符字体加粗
- Javascript实现div的toggle效果实例分析
- datagrid隐藏