views:

326

answers:

2

i am using the jquery datatable plugin. i have the following code that sets up alternative backcolor on an html table.

$('#dependenciesTabletr:odd td').addClass('odd');
$('#dependenciesTabletr:even td').addClass('even');

$('#dependenciesTable').dataTable({
    "bPaginate": false,
    "aaSorting": [[2, "desc"]],
    "bJQueryUI": false,
    "bSortClasses": false,
    "oLanguage": {
        "sSearch": "Filter:"
    },
    "bSort": true
});

the issue is after i sort the alternative backcolor is broken. is there anyway to reset this after each sort ?

A: 

hmm but take a look at this example this plugin provides the odd/even selectors outofthebox you don't need to bind them.

antpaw
but where would you specify which colors you want for the alternative rows?
ooo
+1  A: 

Edit the css for this?

table.display tr.odd.gradeA {
    background-color: #ddffdd;
}

table.display tr.even.gradeA {
    background-color: #eeffee;
}
Fred Bergman