Responsive extensions - JavaScript to expand all child rows.

Responsive extensions - JavaScript to expand all child rows.

andycook71andycook71 Posts: 3Questions: 2Answers: 0

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");
}

Answers

  • allanallan Posts: 52,631Questions: 1Answers: 8,052 Site admin

    Currently no - although this is a good suggestion for a future enhancement - having an API to allow this. Thanks for the suggestion!

    Allan

  • erikduveterikduvet Posts: 7Questions: 2Answers: 0

    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?

  • andycook71andycook71 Posts: 3Questions: 2Answers: 0

    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

  • erikduveterikduvet Posts: 7Questions: 2Answers: 0

    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 :)

  • erikduveterikduvet Posts: 7Questions: 2Answers: 0

    @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.

  • allanallan Posts: 52,631Questions: 1Answers: 8,052 Site admin

    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

  • erikduveterikduvet Posts: 7Questions: 2Answers: 0

    @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"); }

  • allanallan Posts: 52,631Questions: 1Answers: 8,052 Site admin

    I haven't used it myself. I'll try to make some time next week to do so.

    Allan

  • erikduveterikduvet Posts: 7Questions: 2Answers: 0

    Ok, thank you @allan I really appreciate some feedback on this.

  • tracerrxtracerrx Posts: 1Questions: 0Answers: 0

    did anyone ever find a solution to this? I'm interested as well

This discussion has been closed.