Hello,
I don't know how you're using datatables but you should consider using the function fnRowCallbacks.
here's the documentation of such a function:
http://datatables.net/usage/callbacks
However, I had inserted span elements inside the td, so not sure if the above mentioned methods would have worked.
http://awesomescreenshot.com/0822079ge9
However, the way I worked around this issue was the following way (if it helps anyone in future):
[code]
$(document).ready(function() {
$('#example td.control').live('click', function() {
var statues = $('.status-digits');
$(statues).each(function() {
switch ($(this).text()) {
case '7':
$(this).css('background-color', '#90B200');
break;
case '6':
$(this).css('background-color', '#cc9966');
break;
case '5':
$(this).css('background-color', '#ff6699');
break;
case '4':
$(this).css('background-color', '#66ccff');
break;
case '3':
$(this).css('background-color', '#F5F241');
break;
case '2':
$(this).css('background-color', '#cc66ff');
break;
case '1':
$(this).css('background-color', 'orange');
break;
case '0':
$(this).css('background-color', '#ff3333');
break;
case 'null':
$(this).text('');
$(this).css('background-color', 'rgba(0,0,0,0)');
break;
}
});
});
})
[/code]
Replies
I don't know how you're using datatables but you should consider using the function fnRowCallbacks.
here's the documentation of such a function:
http://datatables.net/usage/callbacks
Allan
However, I had inserted span elements inside the td, so not sure if the above mentioned methods would have worked.
http://awesomescreenshot.com/0822079ge9
However, the way I worked around this issue was the following way (if it helps anyone in future):
[code]
$(document).ready(function() {
$('#example td.control').live('click', function() {
var statues = $('.status-digits');
$(statues).each(function() {
switch ($(this).text()) {
case '7':
$(this).css('background-color', '#90B200');
break;
case '6':
$(this).css('background-color', '#cc9966');
break;
case '5':
$(this).css('background-color', '#ff6699');
break;
case '4':
$(this).css('background-color', '#66ccff');
break;
case '3':
$(this).css('background-color', '#F5F241');
break;
case '2':
$(this).css('background-color', '#cc66ff');
break;
case '1':
$(this).css('background-color', 'orange');
break;
case '0':
$(this).css('background-color', '#ff3333');
break;
case 'null':
$(this).text('');
$(this).css('background-color', 'rgba(0,0,0,0)');
break;
}
});
});
})
[/code]
Again, thanks for all the help.
Regards,
Vrutin