Adding CSS styling to hidden columns
Adding CSS styling to hidden columns

Hi, I'm using DT editor and modify row borders as below. However, there are some columns in my table, hidden by default, that I can toggle them back to be visible. Those columns' cells do not get the css styling as the other cells. What could solve this?
Code:
"createdRow": function( row, data, dataIndex ) {
//console.log(data);
// $(row).css('border', 'solid 1px red');
if ( data['coverage'] == 'Uncovered' || data['coverage'] == 'uncovered') {
$(row).addClass('red');
$('td', row).css({'border-bottom': '1px solid black'});
}else if ( data['stat'] == 'warn' ){
$(row).addClass('amber');
$('td', row).css({'border-bottom': '1px solid black'});
//console.log('ok');
}else if ( data['stat'] == 'alert' ){
$(row).addClass('orange');
$('td', row).css({'border-bottom': '1px solid black'});
//console.log('ok');
}else{
$(row).addClass('grey');
$('td', row).css({'border-bottom': '1px solid black'});
}
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Likely the
$('td', row)
selector doesn't find the hidden columns. ThecreatedRow
callback runs only once when the row is created. Try usingrowCallback
instead, it is run each time the table is drawn. You should just need to changecreatedRow
torowCallback
in line 1.Not sure how you are making the column visible but you will need to make sure the table is redrawn. You can use
draw()
if needed.Kevin
Hi, I'm using the 'colvis' button and 'columndefs' for defining columns. How may I use the 'draw' API in such situation? is there another listener or API to capture this event? Thank you.
and
Try the
column-visibility
event.Kevin