Format cell color based on JSON data

Format cell color based on JSON data

ecbahrecbahr Posts: 2Questions: 0Answers: 0
edited July 2012 in DataTables 1.9
I currently have a live datatable that is generated and using bServerSide that is updated with JQuery every 5 seconds. On each query to my database, I grab a bunch of information including a hex value of a color I would like to attach to my data. My question is whether I have to pass that color value as either a hidden JSON column or some mDataProp and do my color/cell processing every 5 seconds, or if I could attach some tag to my JSON data that I could use some sort of HTML or CSS scripting (similar to attaching a to JSON data.

ie

[code]<?php
...
while( $row=odbc_fetch_array($rs)){
$data[]=array(''.$row['foo'],
''.$row['bar'].'');
}
...
$response = json_encode(array(
...
'aaData' => $data
));
echo $response;
?>
[/code]


I hope that makes sense...

Replies

  • koosvdkolkkoosvdkolk Posts: 169Questions: 0Answers: 0
    Personally, I would only provide data, no markup (separation of content and presentation) in the JSON. So e.g. I would communicate a CSS class in stead of colors, and color the rows using CSS
This discussion has been closed.