Responsive extensions - JavaScript to expand all child rows.
Responsive extensions - JavaScript to expand all child rows.
andycook71
Posts: 3Questions: 2Answers: 0
in Extensions
Hi,
I'm using Responsive extensions and I would like to trigger expansion of all the child rows based on an external event (eg a button click).
I've managed to get it to work with the following snippet, but it's pretty ugly manually triggering a click. Wondering if there is a nicer way?
$.fn.dataTable.Responsive.prototype._expandAll = function () {
var dt = this.s.dt;
$(dt.table().node()).find("tr:not(.parent)>td:first-child").trigger("click");
}
This discussion has been closed.
Answers
Currently no - although this is a good suggestion for a future enhancement - having an API to allow this. Thanks for the suggestion!
Allan
andycook71, I am looking for a similar solution. Could you explain how you used this and when, to expand all child rows of a given table? Have you found a nicer solution?
Hi @erikduvet,
I've had a search, but that code never made it into our release and unfortunately I don't have an example of it any more sorry.
You may be able to work out how to call it by examining how the other functions on the Responsive prototype are called?
Andy
Hi @andycook71, thanks for your reply. Yes I am trying to find a solution for this but I have come up short, it feels like there should be some way to do it but simply haven't found a proper one yet. I will continue searching, if you stumble accross something, please let me know :)
@allan Do you have any timeline for when (if) this might be available? Do you have any suggestion for a workaround in the meanwhile? I am desperatley looking for a solution to this.
It isn't something I'm actively working on at the moment. If you want me to take a look at it as a priority, the support options would cover it. The 60 option would probably cover it.
As for a workaround @andycook71's method is the way to do it.
Allan
@allan I tried using the ptototype the following way but I believe that I have missed something, I am very new to JS, ant not sure how I could call it for the specified Table, can you provide me with hte proper way to call the prototype function?
function ExpandTable(){
var tab = j$('[id$="dataTableInfo"]').DataTable();
alert('start: ' + tab);
tab._expandAll();
alert('after');
}
j$.fn.dataTable.Responsive.prototype._expandAll = function () {
var dt = this.s.dt;
$(dt.table().node()).find("tr:not(.parent)>td:first-child").trigger("click");
}
I haven't used it myself. I'll try to make some time next week to do so.
Allan
Ok, thank you @allan I really appreciate some feedback on this.
did anyone ever find a solution to this? I'm interested as well