Reputation: 168
Is there a way to fill a Column of an dojox/grid/EnhancedGrid with SubObjects in a JSON Structure? For example if i have a JSON-Row that is looking like:
{
id: 2,
name: "TestItem2",
created: {
date: "2013-03-28 11:59:40",
timezone_type: 3,
timezone: "Europe/Berlin"
}
}
and I want to fill a Column of the Grid with "date" in SubObject "created". I already tried something like setting the Column's "field" property to "created.date" in the Grid's "structure" Property, but that didn't do the job.
Upvotes: 1
Views: 411
Reputation: 25079
This is kind of evil and lame, but maybe changing the object structure will help you get it into the grid. It sounds like you just want the date, so you could do this:
var o = {
id: 2,
name: "TestItem2",
created: {
date: "2013-03-28 11:59:40",
timezone_type: 3,
timezone: "Europe/Berlin"
}
};
o.created = o.created.date;
Now the object looks like this:
created: "2013-03-28 11:59:40"
id: 2
name: "TestItem2"
Here's a sample from the console:
Upvotes: 0
Reputation: 11561
Apparently you can use a formatter in this case:
var structure = [[
{'name': 'Date', 'field': '_field', formatter: myFormatter }
]];
which will pass the whole node from the store into a function called myFormatter
from which you can pass the relevant entry, like:
function myFormatter(node, rowIdx){
return node.created.date;
};
See also citress' answer here: Dojo grid nested json
Upvotes: 2