EasyUI Forum
September 14, 2025, 10:46:05 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to binding nested JSON Data Object to easyUi dataGrid?  (Read 19022 times)
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« 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..
Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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}}
  ]]
})
Logged
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« Reply #2 on: July 08, 2014, 12:34:07 AM »

you are my hero  Smiley
thanks
Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!