Displaying Nested Object Data in Grouped Rows
Displaying Nested Object Data in Grouped Rows
So as the title says, I am trying to display nested object data in grouped rows. For instance, say I have a categories called computers/laptops, and in the categories I have nested data for a Dell/HP computer and Alienware/Asus laptop. Would it be possible to display that nested data on a separate row but have it grouped to the category row?
Example data (data/objects_deep.txt):
{
"data": [
{
"name": "Computers",
"options": [
"HP",
"DELL"
]
},
{
"name": "Laptops",
"options": [
"ALIENWARE",
"ASUS"
]
}
]
}
Example displayed information image.
I know I can access the nested data with the following code but that displays the nested data in the same row just in an added column. Since, in reality, I will be adding another set of nested data for things like RAM, HardDrives, etc... I would like to created sets of grouped rows below the parent row.
$(document).ready(function() {
$('#example').DataTable( {
"processing": true,
"ajax": "data/objects_deep.txt",
"columns": [
{ "data": "name" },
{ "data": "options.0" },
{ "data": "options.1" }
]
} );
} );
Any advise or examples will help, Thank You.
Replies
No sorry. You'd need to modify the data set. Each array entry in the
data
array is a row in the DataTable, so in the example above there would be two rows.Allan