Hide child datatable

Hide child datatable

wijwijwijwij Posts: 52Questions: 11Answers: 0

Hi,
I want to **hide **a **child **datatable on **select **of row in the **parent **table.
I tried the following code which I found here, but it doesn't work

var tables = $.fn.dataTable.fnTables(true);
$(tables).each(function ()
{
var otable = $(this).dataTable();
$(this).dataTable().fnDestroy();
otable.hide();
otable.parents('div.dataTables_wrapper').first().hide();
} );

Thanks in advance

Answers

  • colincolin Posts: 12,109Questions: 0Answers: 2,059

    If it's a traditional child row, you would destroy the table in the click event like the example here.

    Given your code, it looks like you're doing something different so I suspect we'll need to see this in operation. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • wijwijwijwij Posts: 52Questions: 11Answers: 0

    Thanks, Colin for your reply
    I have designed my parent/child data tables as illustrated in the example here
    All I want to do is show/hide the child data table based on logged in user's role
    So when the user role allows him to see the child data table then show it, otherwise, hide it
    So, I thought it better to embed the script in the row select even of parent database

    Appreciate any help

  • colincolin Posts: 12,109Questions: 0Answers: 2,059

    This example from this thread may help. You would need to do something similar to that,

    Colin

  • wijwijwijwij Posts: 52Questions: 11Answers: 0

    Thank you, Colin.
    I will try the suggested steps in the link

Sign In or Register to comment.