Datatable column visible when value null
Datatable column visible when value null
OmerBenkyzz
Posts: 2Questions: 1Answers: 0
I have a 22 columns on my datatable and i am trying to check my 21 column when string value null unvisible with if,else
how can i do that can u help me
I am trying to check on if, else like that
var table = $('#utable').DataTable();
if (column[21] == empty) {
table.column().visible(true);
table.column().visible(true);
}
else{
table.column().visible(false);
}
This discussion has been closed.
Answers
would always set the visibility of column 0 to
true
- and you've duplicated that command on lines 5 and 6.I'm not too clear on what you're trying to do. Can you add some explanation , please.
Colin
Hey Colin,
hiding will be done according to the state of the row. If the 21st column of a row is empty, that column will be hidden for that row only.
There is nothing built into Datatables to hide a column on a row by row basis. You can hide the whole column.
If you hide the 21st column of only one row whet would happen with the rest of the columns to the right?
Please describe the goal of doing this. Maybe we can offer suggestions.
Kevin
How can you check if a column is empty and hide the column? Actually I know how to hide the column, just having a problem checking if the column is empty.
@tbone Good question. I would use the
filter()
API to get all the column data that is not empty. Then usecount()
to see if there are any non-empty rows. Like this:http://live.datatables.net/rilumati/1/edit
Kevin