Using select extension in nested datatable
Using select extension in nested datatable
Happy Monday campers
Challenge:
I want to have a nested datatable in a child row that's data is updated on ajax.reload() of the first datatable.
The datatable must be able to take advantage of select.
Working:
I can get the datatable to generate by doing the following:
I have a datatable that loads via ajax it has a child rows. I add the child rows in the createdRow callback.
createdRow: function (row, data,index) {
child_row = format(data);
setupChildDataTable(child_row,data.nodes);
current_row = table.row(row);
current_row.child(child_row);
}
function setupChildDataTable(child_row,data) {
$(child_row).dataTable({
select: true,
data: data,
cols: [...],
});
}
function format(data) {
return $('#some_template').clone();
}
This code generates the data table but select does not work on the table.
I did a work around on this using initCompleted callback and constructing the datatable after the load instead of during createdRow, by class name,
this works but unfortunately on ajax.reload() there is no similar callback that has the dom intact to use the class name.
I am aware that the example shows child rows triggered under an on click event but I am trying to maintain the state of being opened on ajax.reload() of the first table.
Any help would be greatly appreciated.
Ted
Answers
I have tried using table.select(), to no avail.
I think this has something to do specifically with child rows and when they are added to the dom.
Ted