Coloring a row depending on a hidden field and an array or db entry.
Coloring a row depending on a hidden field and an array or db entry.
phantom001
Posts: 2Questions: 0Answers: 0
Hello
I am new to DataTabels and absolut no idea how to solve it ... hope some one can help.
I have a hidden field with lets say rose, ocan, sand .... in it.
Then I have entrys in a DB (provided as array) with two colums thing and color.
So one of the records may be rose ---> #FF0000 (red).
I want everytime when the hidden field contains rose that the backround of the row changes to the color #FF0000 or when it contains ocan its change to color #0033FF (blue) and so on.
But i have no idea how to hook in :-(
THANK YOU !
I am new to DataTabels and absolut no idea how to solve it ... hope some one can help.
I have a hidden field with lets say rose, ocan, sand .... in it.
Then I have entrys in a DB (provided as array) with two colums thing and color.
So one of the records may be rose ---> #FF0000 (red).
I want everytime when the hidden field contains rose that the backround of the row changes to the color #FF0000 or when it contains ocan its change to color #0033FF (blue) and so on.
But i have no idea how to hook in :-(
THANK YOU !
This discussion has been closed.
Replies
Allan
Hello
Thx allan for the answer but i didnt get along with it because i get the data from a json Dataset and dont create the table row by row ...
But after some Time i found a solution and its so simple :-)
I have just used fnRowCallback
Example:
In the if i check if the datafield value matches somthing in this example "10"
If it match i color the row in this case red with the .css selector , <td> and nRow (the actual row).
"fnRowCallback":function(nRow, aData) {
if (aData[4] == "10")
{
$('td', nRow).css({"background-color":"red"});
}
}
So i can check if the value matches my color values and coloring the rows.
Thanks
Nice one :-)
Allan
thanks it's ok to color a row when a value is null