views:

31

answers:

1

How can I attach a class to the row I'm adding in the datatable, if not possible, how Can i Use fnRowCallback or fnDrawCallback to change the class.

Thanks for your help!

(Please be explicit)

        oTable = $('#example').dataTable( {
            "bJQueryUI": true,
            "bSortClasses": false,
            "sDom":'T<"clear">',
            "sPaginationType": "full_numbers",
            "sDom": 'T<"clear"><"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>t<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>',
            "fnRowCallback": function( nRow, aData, iDisplayIndex ) {

                var oSettings = oTable.fnSettings();
                 oSettings.aoData[iDisplayIndex].nTr.className = "gradeX odd";
            }
        } );

giving me an error

this is how I add the row:

 oTable.fnAddData(arr);
A: 

Alright, perhaps I'm not understanding exactly what your question is, but if you were just adding the row, why not set the class before you add it? Like this, somewhat sloppy, example:

jQuery("<tr />")
  .html(your_var_containing_the_interior_dom)
  .addClass("yourClass")
  .appendTo(jQuery("#yourTable"))
jasonpgignac