I have a nested dataset. Few records in the dataset are child to other records in the same dataset. The records that have parent as null do not have any child elements, but ones that has value associated with is will indicate its parent in same dataset. How do I represent this in jQuery Datatable with Parent Child relationship.
I have just manipulated the common dataset to explain my requirements. As in the dataset example below, Record with Name - Tiger Nixon have two child records, which are as seperate records in the same dataset.
An example of how to achieve would be of great help.
{
"data": [
{
"name": "Tiger Nixon",
"parent": "null",
"position": "System Architect",
"salary": "$320,800",
"start_date": "2011/04/25",
"office": "Edinburgh",
"extn": "5421"
},
{
"name": "Garrett Winters",
"parent": "Tiger Nixon",
"position": "Accountant",
"salary": "$170,750",
"start_date": "2011/07/25",
"office": "Tokyo",
"extn": "8422"
},
{
"name": "Ashton Cox",
"parent": "null",
"position": "Junior Technical Author",
"salary": "$86,000",
"start_date": "2009/01/12",
"office": "San Francisco",
"extn": "1562"
},
{
"name": "Cedric Kelly",
"parent": "Tiger Nixon",
"position": "Senior Javascript Developer",
"salary": "$433,060",
"start_date": "2012/03/29",
"office": "Edinburgh",
"extn": "6224"
}
]
}
You can use
ajax.dataSrc
to store original data ing_dataFull
and filter and return data containing parents only to be displayed in the main table.When child row is being in
format()
function you need to iterate full datasetg_dataFull
and find and display rows containing children (this.parent === d.name
).