Change row color when a value is the same
Change row color when a value is the same
Hi, I'm using Datatables and I'd like to know if is possible to group rows and change color if 1 column has the same value.
Name | Surname | UniqueID
lolo | tus | 111111111
lolo | tus | 111111111
lolo | tus | 22222222
lolo | tus | 33333333
lolo | tus | 33333333
lolo | tus | 44444444
lolo | tus | 111111111
lolo | tus | 111111111
lolo | tus | 111111111
In the column UniqueID I have some repeat values, could I "group rows" (1-2),
(3), (4-5), (6), (7-8-9), only change the rown colours.
I know I can if uniqueid=11111111 set color orange, if uniqueid=22222222 set color to red... but I don't want this. I don't know the value of Uniqueid, so i need change the row color when Uniqueid Up and down of the row has the same..
I don't know if I explain correctly..
is it possible?
Thanks
Answers
One option might be to use the RowGroup Extension to group the rows.
If you don't want to use RowGroup then I would look at using
drawCallback
. In thedrawCallback
userows().every()
to loop the rows. In the loop keep track of the uniqueid and when it changes apply the appropriate classname name to highlight the row.You will probably want to use the
selector-modifier
of{page:'current'}
to limit the highlighting to the page being displayed.Kevin
Hi Hevin, thanks...
Sound good, can you borrow me some example?
Thanks
Here is an example:
http://live.datatables.net/wojitela/1/edit
It uses the following API's:
rows().nodes()
rows().every()
row().data()
row().node()
The CSS tab has the highlight CSS to work with the default Datatables styling.
Kevin