Conditional formatting on @data-order value
Conditional formatting on @data-order value
Hello. I have a table listing invoices, and am trying to highlight rows based on their due date and balance.
PHP is my native language and I barely know javascript, so please bear with me if I seem stupid. I feel like I am really close but have been spending hours on this table.
To begin with, I have found the conditional formatting example on this website, and it works as expected on data displayed within the <td></td> tags. I was successful in adding the class 'open' to the row based on the formatted text (hard number coded for testing):
rowCallback: function(row, data, index) {
if (data[5].display=="$ 1,012.17") {
$(row).addClass('open')
}
}
So I just need to figure out how to refer the evaluation statement to the @data-order attribute because I want to do a " > 0 " evaluation on the field. I know it is just a dumb syntax question, but I am just dying here.
I tried:
if (data[5].display==1012.17)
and
if (data[5]==1012.17)
and
if (data[5].data-order==1012.17)
and
if (data[5].@data-order==1012.17)
and
if (data[5].data-order=='1012.17')
and
if (data[5]=='1012.17')
...
Here is my debug: debug.datatables.net/afiyaf
The code is on a private server, but here is a fiddle: https://jsfiddle.net/s0k03k7r/10/
Thanks in advance for any clues that could help.
EDIT: I should have put the sample table up so you don't have to search the links.
<tr>
<td><a href='#'>1047</a></td>
<td data-order='20080201'>02/01/2008</td>
<td>Customer 1</td>
<td data-order='20080301'>03/01/2008</td>
<td data-order='2500'>$ 2,500.00</td>
<td data-order='0'>$ 0.00</td>
<td>Printed</td>
<td> </td>
</tr>
<tr>
<td><a href='#'>1048</a></td>
<td data-order='20080405'>04/05/2008</td>
<td>Customer 2</td>
<td data-order='20080505'>05/05/2008</td>
<td data-order='1012.17'>$ 1,012.17</td>
<td data-order='1012.17'>$ 1,012.17</td>
<td>Printed</td>
<td> </td>
</tr>
<tr>
<td><a href='#'>1049</a></td>
<td data-order='20170928'>09/28/2017</td>
<td>Customer 1</td>
<td data-order='20171028'>10/28/2017</td>
<td data-order='487.05'>$ 487.05</td>
<td data-order='487.05'>$ 487.05</td>
<td>Printed</td>
<td> </td>
</tr>
Thanks Again.
Answers
Eureka!
I persisted, and found the syntax.
I hope this helps someone else out there, since I found absolutely no examples of this being done...
Please mark this question as Answered.