Mark some rows depending on database contents
Mark some rows depending on database contents
lol_user
Posts: 10Questions: 4Answers: 0
Hello
I need to know is that possible to have some row marked in the table according to the value of some field in the database .
For example: the table shows me the result of the following select:
"select sysname,address,ip,active from AAA ";
I want to highlight(or mark) those rows , whose corresponding data have 'active=0' and not mark those with 'active=1'
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Seems like another similar question in the forum here:
https://datatables.net/forums/discussion/38212/table-row-conditional-styling#latest
I posted an example there too.
And here is another codepen example, making use of
columns.createdCell
which I only recently found.Codepen example
Thank you very much,
columns.createdCell works though I only managed to chahge the color of <td> and cannot find how to change the color of a whole row...
The row parameter in the function call, gives you the index number of the table row where the current cell check is done. So you have to use that, but remember that it is zero based. If you use this row index in css then you have to add 1 to it. Example:
You can replace #example with your table id or if you used a class, the classname.
Thank you very much. But for some reason it does not work. Just no any changes in table view. Though with 'td' it works..
I see only 2 possibilities here. Maybe ScrollY has something to do with it, but I doubt that. The other is that the css for the table row is overruled. In the latter case, try making a css class like:
Make sure that the css file where this is in, is loaded last. And then change the js to this:
Still no success. It seemes this construction with 'tr:nth...' has completely no effect.
Thank you anyway.