Search code examples
footable

How To hide FooTable Columns Dynamically?


I have tried this code but it works for once but not every time.

$('.rptEmail').attr('data-ignore','true');
$('.rptEmail').attr('data-hide','all');
 $('#ReportMainGrid').trigger('footable_redraw');

I have tried other trigger also but nothing works properly.


Solution

  • I'm surprised no one else has had this problem. After pecking around the code, it looks like the data attributes for the rows are pulled using the .data() jquery function. The problem with this is (from what I understand) the function will populate on initial page load. What this means is, even though you change the data-hide attribute with .attr(), .data() will still hold the old value.

    To get around this, without touching the Footable code, you can simply use the .data() function to change the column's property.

    $("PATH_TO_TH").data("hide", "all");      //Set this to whatever you'd like
    $('.footable').data('footable').reset();
    $('.footable').footable();