Show details automatically for some selected rows

Show details automatically for some selected rows

zx81zx81 Posts: 9Questions: 2Answers: 0
edited September 2020 in Free community support

Would it be possible to show the additional details row automatically for some rows based on a specified condition ?
Alternatively I would not mind creating a javascript function that displays the detail of a particular row but I could not figure it out.

Replies

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951

    You can loop all the rows using rows().every(). In the loop you can check for your condition then use row().child().show() to show the child. You can do this in initComplete or draw or whatever event suites your purpose.

    Kevin

  • zx81zx81 Posts: 9Questions: 2Answers: 0

    Thanks. I still can't figure out the exact line to lets's say show the detail row of the first row
    I tried $('#myTable').DataTable().row(0).child.show() among many other things.

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951

    Here is an example of what I described to open rows base on a condition. In this case Office === London:
    http://live.datatables.net/toqedesi/1/edit

    I tried $('#myTable').DataTable().row(0).child.show()

    In order for row().child.show() you need to attach the child row first using row().child() to apply the row data. Did you do that?

    If you still need help please update my test case or create you own with what you need help with.

    Kevin

  • zx81zx81 Posts: 9Questions: 2Answers: 0

    Fantastic! Thanks a lot Kevin. Much appreciated.

This discussion has been closed.