EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: aswzen on July 07, 2014, 08:01:44 PM



Title: How to binding nested JSON Data Object to easyUi dataGrid?
Post by: aswzen on July 07, 2014, 08:01:44 PM
Yes..how you can do that??

example i have JSON

Code:
{"total":2,"rows":[{"productid":"1","attr":{"size":"10","color":"red"},
                    {"productid":"2","attr":{"size":"202","color":"green"}]

i can't output the 'size' and 'color' attribute..
Already tried with

Code:
{field:'attr.size',title:'Product Size',width:250},
{field:'attr.color',title:'product Color',width:100},

But it doesn't work....

Help me..

Thanks in advance

nb : Don't refer me to StackOverflow answer..


Title: Re: How to binding nested JSON Data Object to easyUi dataGrid?
Post by: stworthy on July 08, 2014, 12:21:45 AM
Please use 'formatter' function to format your column values.
Code:
$('#dg').datagrid({
  data:data,
  columns: [[
    {field:'attr.size',title:'Product Size',width:250,formatter:function(value,row){return row.attr.size}},
    {field:'attr.color',title:'product Color',width:100,formatter:function(value,row){return row.attr.color}}
  ]]
})


Title: Re: How to binding nested JSON Data Object to easyUi dataGrid?
Post by: aswzen on July 08, 2014, 12:34:07 AM
you are my hero  :)
thanks