I need to hide a column from showing up in jquery datatables. When I hide the column using bVisible property it disappears from the DOM.
I want to set display property of table cells of a column to none so that the values do not appear in the view but they should still be present in the DOM as the column I am hiding identifies the row uniquely and I need to know the unique ID on row select. How to achieve this.
I am populating the table using aaData property using server side pagination.
Had a look at this question but these options remove it from the DOM. jquery datatables hide column
You can use the method
hide
.To show the element, use the method
show
:To get the column that you want, you can use
n-th child
selector from jquery.this is my contribution for u.
Not sure if the code is correct but its work.
If u do have more than one setup column like me.
If you want to hide multiple columns:
To build on Daniel's answer:
css:
In datatables init:
Remember to add your hidden class to your thead cell also:
This is also a useful strategy if you're using server-side processing and want to pass in data from the ajax source without it being visible in the datatable. You'll still be able to retrieve the column's value on the front-end without needing to display it. Helpful for filtering via hidden data values etc.
Example:
You should use
className
along with the columnDefs or the columns,Define
hide_column
class in your css like thisYou have two ways to assign that
.hide_column
class:Use
columnDefs
(assign custom class to first column):OR
columns
code snippets taken from here
Old answer
Try adding
that should make that column hidden...