Need a little help - very new to Datatables, and I'm not a programmer..
I want to modify the style (color) of the data in one column based on the value of the data in another column of the same row.
A simple example:
I understand that I want to use mRender, but I don't quite get how to put it all together. I've successfully added a test span based on the following example I found elsewhere in the forums:
but I don't understand what mData: "0" is referring to in this case, and how to get the data from column [0] and evaluate it, before returning the wrapped data for column [1]
can somebody give me a nudge in the right direction?
Thanks!
I want to modify the style (color) of the data in one column based on the value of the data in another column of the same row.
A simple example:
<table> <thead> <tr> <th>Foo</th> <th>Bar</th> </tr> </thead> <tbody> <tr> <td>.21</td> <!-- if this Foo number is less than .25... --> <td>34</td> <!-- then this Bar number gets wrapped in a span --> </tr> </thead> </table>
I understand that I want to use mRender, but I don't quite get how to put it all together. I've successfully added a test span based on the following example I found elsewhere in the forums:
"aoColumnDefs": [ { "aTargets": [ 1 ], "mData": "0", "mRender": function ( data, type, full ) { return '<span class="test">'+data+'</span>'; } }
but I don't understand what mData: "0" is referring to in this case, and how to get the data from column [0] and evaluate it, before returning the wrapped data for column [1]
can somebody give me a nudge in the right direction?
Thanks!