class
class
https://live.datatables.net/vohiyelo/3/edit
Error as seen in the test case:
Trying to add two classes to all odd rows.
How to add two classes to all odd rows that needs to work with both client side and server side process?
https://live.datatables.net/vohiyelo/3/edit
Error as seen in the test case:
Trying to add two classes to all odd rows.
How to add two classes to all odd rows that needs to work with both client side and server side process?
Answers
That will remove the
oddclass from any existing rows in the body (for cases when a row was odd, but has been moved to become even!), and then adds it on.However, if it is just for styling, then just use CSS:
Allan
Thanks for the reply.
Two more matters to get clarity.
1- Difference between (in simple words)
a) "rowCallback": function ()
b) "drawCallback": function ()
2 How to add it rowCallback / drawCallback function on a button click ?
george.
The
option rowCallbackanddrawCallbackdocs explain it best.You can use a
console.log()statement in each callback to see the behavior and when the run.Call
draw()to execute theoption rowCallbackanddrawCallbackfunctions.Kevin
Thanks for the reply.
Actually don't know the logic required to add the below with a button click
"drawCallback": function () {
$('#example tbody tr').removeClass('odd');
$('#example tbody tr:odd').addClass('odd')
}
can you show me onetime ?
george
Like this:
https://live.datatables.net/vohiyelo/7/edit
Not sure having a button for just redrawing the table to execute that particular code in
drawCallbackis very useful.drawCallbackwill run anytime the table is drawn for example anytime the table is sorted, searched or changing the page.What are you trying to do with the button?
Kevin
What are you trying to do with the button?
Answer - only call or function the 'drawCallback' on that button click.
I don't know that 'how to do that.
george
As I said to execute the
drawCallbackfunction call thedraw()API. This is what my example shows:https://live.datatables.net/vohiyelo/7/edit
However maybe you just want to execute an independent function when clicking a button. Something like this:
https://live.datatables.net/vohiyelo/9/edit
Sorry, I'm still not clear on what exactly your requirement is.
Kevin