Took a bit to work this out but the biggest issue is getting the proper row API. You had var _row = this; instead it needed to be var _row = childDataTable.row(this);. Note that I'm now getting the child Datatable API instance with childDataTable = $('#cl' + id).DataTable({ ... });. I also added the level 2 child Datatable init code. Here is the updated example: http://live.datatables.net/heqijuji/1/edit
I see two issues:
When reopened the level 2 child shows different data. I didn't look at your code to get this data.
After the reload I see errors like this when clicking the level 2 child:
runner:19 Uncaught TypeError: Cannot read property 'matterID' of undefined
Sounds like, for both issues, the re-opened children aren't getting the correct data. I'll let you look into this
Hey Kevin @kthorngren ! Thanks for the solution. I've solved the data source problem. But I'm not able to detect the reason for the 2nd issue mentioned by you above.
When I open multiple rows and then reload, only the 1st row is showing this error the rest are working fine.
For some reason the variable childTable is becoming undefined causing the error. In the click event I make sure to obtain the API for the Datatable, I added this to the click event:
// Add event listener for opening and closing second level childdetails
$('tbody').on('click', 'td.details-control1', function () {
var tr = $(this).closest('tr');
// Get API instance of table
var table = $(this).closest('table');
childTable = (table).DataTable();
Answers
@kthorngren I've corrected the error mentioned above.
http://live.datatables.net/nuhopemu/33/edit
The output tab only displays the Table Head and Reload button. That's why I'm not able to view any error before sharing with you. Hope you don't mind.
Kevin Bro, thanks for sticking for so long.
Took a bit to work this out but the biggest issue is getting the proper row API. You had
var _row = this;
instead it needed to bevar _row = childDataTable.row(this);
. Note that I'm now getting the child Datatable API instance withchildDataTable = $('#cl' + id).DataTable({ ... });
. I also added the level 2 child Datatable init code. Here is the updated example:http://live.datatables.net/heqijuji/1/edit
I see two issues:
Sounds like, for both issues, the re-opened children aren't getting the correct data. I'll let you look into this
Good job putting this together!
Kevin
Hey Kevin @kthorngren ! Thanks for the solution. I've solved the data source problem. But I'm not able to detect the reason for the 2nd issue mentioned by you above.
When I open multiple rows and then reload, only the 1st row is showing this error the rest are working fine.
Any idea as to why this is happening?
For some reason the variable
childTable
is becomingundefined
causing the error. In the click event I make sure to obtain the API for the Datatable, I added this to the click event:Here is the updated test case:
http://live.datatables.net/heqijuji/2/edit
Kevin