Row background color the same for all rows after initialisation
Row background color the same for all rows after initialisation
I initially load my page with a html table with one dummy row of data. The user can then apply filters to retrieve data from a database via jquery and ajax. The table loads fine but all rows have the same color (light purple), no alternating row colors. I do have the Smoothness themeroller applied as well.
On $document ready I have:
var oTable = $('#usrSearch').dataTable({
"bJQueryUI": true,
"sScrollY": "500px",
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [0] }
]
});
This is to format the dummy row and table so it looks good on initial load.
The user then clicks a button that gets new data from ajax and before loading the table with data I do this:
oTable = $('#usrSearch').dataTable();
oTable.fnClearTable();
and then I fill the rows of the table with new data and then I initialise the table using:
oTable = $('#usrSearch').dataTable({
"bJQueryUI": true,
"sScrollY": "450px",
"bPaginate": true,
"sPaginationType": "full_numbers",
"bStateSave": true,
"bLengthChange": true,
"iDisplayLength": 50,
"aLengthMenu": [[50, 100, 500, -1], [50, 100, 500, "All"]],
"aaSorting": [[9, "desc"]],
"aoColumnDefs": [{ "bSortable": false, "aTargets": [0]}],
"bDestroy": true
});
The table loads fine and everything looks great via the themeroller except that all of the rows have the same color background, not alternating.
Do I need to change something?
Also, where do I change the alternating background colors default color in CSS?
Thanks!
On $document ready I have:
var oTable = $('#usrSearch').dataTable({
"bJQueryUI": true,
"sScrollY": "500px",
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [0] }
]
});
This is to format the dummy row and table so it looks good on initial load.
The user then clicks a button that gets new data from ajax and before loading the table with data I do this:
oTable = $('#usrSearch').dataTable();
oTable.fnClearTable();
and then I fill the rows of the table with new data and then I initialise the table using:
oTable = $('#usrSearch').dataTable({
"bJQueryUI": true,
"sScrollY": "450px",
"bPaginate": true,
"sPaginationType": "full_numbers",
"bStateSave": true,
"bLengthChange": true,
"iDisplayLength": 50,
"aLengthMenu": [[50, 100, 500, -1], [50, 100, 500, "All"]],
"aaSorting": [[9, "desc"]],
"aoColumnDefs": [{ "bSortable": false, "aTargets": [0]}],
"bDestroy": true
});
The table loads fine and everything looks great via the themeroller except that all of the rows have the same color background, not alternating.
Do I need to change something?
Also, where do I change the alternating background colors default color in CSS?
Thanks!
This discussion has been closed.
Replies
$("#usrSearch tbody tr").each(function () {
$(this).mouseover(function () {
color = $(this).css("background-color")
$(this).css("background-color", "#A9D1DE");
}).mouseout(function () {
$(this).css("background-color", color);
});
});
I remmed it out and the table looks fine now. Can this still be applied and also have the alternating row colors or not?