render table from array, using fnRender, how to set an extra class on row element?

render table from array, using fnRender, how to set an extra class on row element?

saelfaersaelfaer Posts: 2Questions: 0Answers: 0
edited August 2010 in General
hi,

i've been struggling to convert my extensive scripts into a better solution
since i get json from the server, i do not need to first create a dom table and then datatable it.

after rewriting most of my code, with the fnRender option for the custom fields.
i'd like to know how i can handle an extra class on a row.

its easy when you build the table manually, you can add classes or other manipulations anywhere
but the fnRender only lets you return a html string for the field itself

any idea how i can add a class to the row?
do I even need the fnRender for it?
i was trying to build it from within an fn render, and then print the value of the field in the class property of the row (then hide that column)
but 1) i cannot access the row from within the fnRender function
2) that is very dirty, and i was looking to optimize it, not make it even more dirty :P

hope someone has some good input
thanks in advance
Sander

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    fnRowCallback can be used to modify the created / controlled DOM elements:

    Documentation: http://datatables.net/usage/callbacks#fnRowCallback
    Example: http://datatables.net/examples/advanced_init/row_callback.html

    Allan
This discussion has been closed.