Multilevel expandable datatables from Json

Multilevel expandable datatables from Json

lucaszoltowskilucaszoltowski Posts: 1Questions: 1Answers: 0

Hello I need to load a multi-level json file into datatables with expandable rows, but those rows need to contain other expandable datatables based on the traversal of the json file.

Example that is here no longer seems to work but is the closest I could find: https://stackoverflow.com/questions/30505778/displaying-hierarchical-data-with-jquery-datatable

The actual layout of the json I am trying to work with is here,
https://www.dropbox.com/s/f15nj542t4go8wt/elo.json?dl=0

Any help would be greatly appreciated.

Answers

  • allanallan Posts: 50,303Questions: 1Answers: 7,478 Site admin

    Hi,

    DataTables doesn't do nested child rows as such, but you can certainly put another DataTable inside a child row. You just need to insert the HTML for the new table and then initialise it:

    table.row(...).child( createChildTable(row.data()) ).show();
    $('#newTableId').DataTable(...);
    

    You'd need to know the new id of the table (perhaps return the html for the table and the id in an object from the create function), but that's the basic way of doing it.

    Allan

Sign In or Register to comment.