jqueryajaxdatatablespaginationcallback

How to hide or show a column after a jquery data table AJAX callback


Using JQuery data tables it is easy to retrieve the content of the table using AJAX . The problem I am having us the ability to hide or show a column as the user pages through the data. In the table there is a column with a check box but not all the rows will have the checkbox. If the current page does not have any rows with checkboxes how do I hid that column and them have it be shown when to user pages (using the data table paging functionality) to a page with rows containing text boxes?


Solution

  • I found the answer:

    In fnDrawCallback, call this.fnSetColumnVis( 5, true); to show the 6th column (0 is the first column) and this.fnSetColumnVis( 5, false); to hide that same column.