Collapsible table with data table plug-in
Asked Answered
D

2

6

I am using data table plug-in for pagination..Now I want collapsible feature on click of every row of table...

This is a snippet of my code :

 <tr class="outer-tr">
     <td>1</td>
     <td>pppol</td>
     <td>Approved</td>
</tr>
<tr class="inner-tr"> 
       <td>show-hide</td> 
</tr> 

And I am hiding/showing inner-tr on click of outer-tr.
But it gives an error:

 Uncaught TypeError: Cannot read property 'className' of undefined 

I know this happens because of improper table format..

Any suggestion to achieve collapsible table with data table plug-in???

Debrahdebrecen answered 31/3, 2014 at 5:4 Comment(1)
You need to provide you javascript for rendering the tableCimino
C
0

Add jquery script in your code:

$(function() {  
   $('.outer-tr').click(function() {
      $('.outer-tr td').toggleClass('visible');
   });
   $('.inner-tr').click(function() {
      $('.inner-tr td').toggleClass('visible');
   });
});

Also add a css style

tr td{display: none;}
tr td.visible{display: block;}
Cheiro answered 7/4, 2014 at 12:2 Comment(0)
A
0

the JQuery DataTable documentation explains it here, provide your JS code if you need more help.

Atahualpa answered 14/5, 2021 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.