Expand/Collapse all row details, next page

Expand/Collapse all row details, next page

rockdalrockdal Posts: 3Questions: 0Answers: 0
edited May 2013 in DataTables 1.9
Thanks in advance.

I have been looking through the forums and really have not found an answer. This discussion (http://www.datatables.net/forums/discussion/10606/solved-how-to-add-button-to-expand-all-details/p1) came close, but did not solve my issue.

I want to have an expand (plus)/ collapse (minus) in the first column . I have it working where it expands and collapse all the 'displayed' records. The problem starts when I go to the next page. No details are showing. So I thought, if I could check which icon was displaying, I would open or close detail when the pagination was triggered. But I have not found an example of how to do something like this when moving from one page to the next or backwards. I would also need to check when searches are being done. Basically, if the datatable changes, i need to check if the user had the expand all icon selected, or the - selected.

Any direction or hints?

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    > The problem starts when I go to the next page

    Sounds like the top FAQ: http://datatables.net/faqs#events . However, please link to a test case so we can actually ofter some help rather than just guessing ( http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read ).

    Allan
  • rockdalrockdal Posts: 3Questions: 0Answers: 0
    Allan,

    Thank for getting back so quickly. I read the faqs, but need to do more thought into the example and how to make it work for my case.

    But I did go to the test cases and created one (http://live.datatables.net/ofuyub/9/edit#preview). As you see, I can open individual rows and I can open all of the rows on the visible page. But when I go to next page, if the rows are expanded, the new rendering rows are closed but my (global expnd) icon is a minus and no rows are expanded.

    This would also be the case when doing searches and show entries. I do not show in the example, but I also do searches on the columns.

    I hope this help. And thanks in advance.

    Anthoney
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    I think this is a selector / DOM issue. The thing to remember is that DataTables removes rows which are not needed from the DOM. So a standard jQuery selector will not find those elements. You need to use the $ API method to get all TR elements in the DataTable: http://datatables.net/docs/DataTables/1.9.4/DataTable.html#$

    Allan
  • rockdalrockdal Posts: 3Questions: 0Answers: 0
    Allan,

    Thank you so much. I got it working (http://live.datatables.net/ofuyub/14/edit). Someone with more advanced jQuery skills could probably do it in less code, but this is good enough for the girls I run around with.

    Anthoney
This discussion has been closed.