jQuery DataTables: How to expand/collapse all child rows

jQuery DataTables plug-in has native support for child rows with row().child API methods. Child rows can be used to show extra details that do not fit into the main table. These rows are initially hidden and can be shown by clicking on expand/collapse control .

Child rows are also used by Responsive extension to display columns that do not fit the screen.

Solution depends on whether you use Responsive extension for your table powered by jQuery DataTables.

Expand/collapse child rows in a regular table

There is an example on DataTables website demonstrating how to use child rows. I used it to show how to open all child rows in a regular table.

Expand/collapse child rows in a table with Responsive extension


Opening all child rows in a table with Responsive extension requires a different approach.

We need isolate rows that have child rows closed. These rows will not have parent class. Then we need to trigger a click event on the first cell of such row to force Responsive extension to expand a child row.



You May Also Like


  1. From the Stackoverflow answer you provided, that is exactly what I’m looking for!  No clue why I couldn’t ever find a table inside a table approach.  thank you for that.  Also, I have to apologize as I’m a beginner JavaScript/jQuery dev, but do you have an example of doing that same way but the data is coming from a SharePoint REST API call to a list?

  2. Is it possible to make column values clickable to see more details.

    Lets say, if i click Chief Executive Officer (CEO) i see details related to CEO and if i click on  London i see details related to London.

    So basically i want to replace collapse and expand functionality of button with columns values.

  3. Hi,
    I went through your article and also i have implemented it in my code.its working fine.but the thing is that now i got new requirement like expanding single row at a time i.e. if i click on first row it will expand now if click on second row then first row should get collapse and second should get expand. how can i do that? could you please help me out with that?

  4. Hi,

    thank you for your article. Is it possible to expand all columns in all pages? At the moment this works only in the first page.

    I thank you in advance,


Leave a Reply


This site uses Akismet to reduce spam. Learn how your comment data is processed.