lose class at row after redraw of the table
lose class at row after redraw of the table
Hi,
how should I add a class to a -tag if I have to make a redraw the table??
After the fnDraw the additional class is lost :(
$('tr.xxxxx').live('click', function () {
$(this).addClass('row_selected');
... insert rows (_fnAddData) ... do something ...
oTable.fnDraw();
});
How can I do this without to lose the new class??
Thank you!
Dieter
how should I add a class to a -tag if I have to make a redraw the table??
After the fnDraw the additional class is lost :(
$('tr.xxxxx').live('click', function () {
$(this).addClass('row_selected');
... insert rows (_fnAddData) ... do something ...
oTable.fnDraw();
});
How can I do this without to lose the new class??
Thank you!
Dieter
This discussion has been closed.
Replies
The extra class will be kept on the row, as long as it is using client-side processing (which I think you are).
Here is an example showing that: http://live.datatables.net/ehuloj/edit . It adds a class to the last row to make it background: grey, and then does a draw.
Allan
this is exactly what I am doing:
$('#palreport tbody tr.hassub').live('click', function () {
..... ajax-call to get data .....
// mark the parent row as selected
$(this).addClass('row_selected');
// insert the new rows after the parent row
addnewRows(nTr,data);
});
function addnewRows(aTr,data) {
for (var i = $(data.aaData).length-1; i >= 0; --i) {
oTable.fnAddAfter(aTr,$(data.aaData)[i], false);
}
oTable.fnDraw();
}
Before the "oTable.fnDraw();" the class is set correctly ... after that the class is the same as before :(
Dieter
It is generally much better to use jQuery's addClass and removeClass, particularly if you don't want to overwrite some old classes.
Allan