Dynamically set className of a column

Dynamically set className of a column

kaushalparik27kaushalparik27 Posts: 1Questions: 1Answers: 0

I am trying to hide and show columns without removing it from DOM.
So far, I am able to hide columns first in DataTable initialization. But, I am not able to show columns back via Javascript. Here is what I am trying:

//-- here oTable refers to DataTable. Code is trying to show 5th column by setting a css class that has display: block style
oTable.column(5).className = "show_column";

But, this is not working. Anybody can help?

Answers

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    You could try using column().nodes() which will give you the cells for the column. You'd also need to use column().header() and column().footer(). You'd also need to take account of any rows that are added or dynamically rendered.

    Why don't you want them removed from the DOM? You can still access the data for them.

    Allan

This discussion has been closed.