Server Side custom depending on value
Server Side custom depending on value
Hi, I want to use server side, because when I use client side and i get and loads tons of data from database it took a minute before the page loads completely, I tried server side and it resolves the problem.
the only thing I need to do is to customize <tr> on each of the row depends on their value,
for example I have loaded tables of licenses, I want to customize <tr> of expiring license so that the end user will classify it as expiring
e.g:
[ ID ] [ Name ] [ License No. ] [ Expiration ]
[ 1 ] [ USER1 ] [ LIC001 ] [ 07-07-2017 ]
[ 2 ] [ USER2 ] [ LIC002 ] [ 12-07-2016 ] <style tr to classify it as expiring>
[ 3 ] [ USER3 ] [ LIC002 ] [ 20-03-2017 ]
[ 4 ] [ USER4 ] [ LIC002 ] [ 18-04-2017 ]
[ 5 ] [ USER5 ] [ LIC002 ] [ 30-05-2017 ]
[ 6 ] [ USER6 ] [ LIC002 ] [ 08-06-2017 ]
[ 7 ] [ USER7 ] [ LIC002 ] [ 05-07-2017 ]
This question has accepted answers - jump to:
Answers
Hi? anyone can help me please? I just want to style the background of specific tr's depending on their value
Use
rowCallback
to customise thetr
element (.e.g adding a class).Allan
thanks allan.. ill look for it
I solved this using rowCallback, but I still have another question styling td I use this code
"rowCallback": function( row, data, index ) {
if (data[1]<data[2]) {
$('td', row).css('background-color', '#ff5559');
}
here is the question,
what if I will get data and compare it to data[1] from the database that is not displayed on the table. is it possible?
for example I will get data's from another table with specific ID I define to compare it in data[1] and style a td..
Yes - you can get the data from anywhere you want. Just obtain it as you would from anywhere else -
$('#myId').text()
for example.Allan
thanks allan.. your the man