Conditional Formatting of AJAX sourced cells

Conditional Formatting of AJAX sourced cells

deckdeck Posts: 1Questions: 0Answers: 0
edited April 2012 in DataTables 1.8
Hello. First time poster, 1 year user.

I'd really like to apply conditional formatting to some cells in my AJAX sourced datatable. My init looks something like this:

/myScript.js[code]var oTable = $('#myTable').dataTable(
"bProcessing": true,
"sAjaxSource": "myData.php",
"aoColumns": [
{"mDataProp": "name"},
{"mDataProp": "is_cool"},
{"mDataProp": "age"},
...[/code]

and

/myPage.html[code]...



Name
Cool
Age
...[/code]

Lets say I'd like to apply a 'kid', 'adult', or 'senior' class to each td in the 'age' column of my dataTable where 'age' is a number. I've looked into using fnCreatedRow and fnRowCallback (http://datatables.net/usage/callbacks), but I don't want to be referencing by index (that's why I'm using mDataProp in the first place.) Is there a clever way to (for example) add the 'senior' class to the 'age' td's for ages greater than 60?

I'm already using fnRender to add commas and fix sig figs to certain column values... is here the appropriate place to do that? (something like this.parent('td').addClass() ?)

Thanks in advance everyone. I'll fiddle with this in the meantime and post back if I figure it out.

DT is prob. my fav. jquery plugin. Thanks Allan.
This discussion has been closed.