1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
<?xml version="1.0" encoding="UTF-8" ?>
<dt-option group="callback">
<name>rowCallback</name>
<summary>Row draw callback.</summary>
<since>1.10</since>
<type type="function">
<signature>rowCallback( row, data, displayNum, displayIndex, dataIndex )</signature>
<parameter type="node" name="row">
`tag TR` element being inserted into the document.
</parameter>
<parameter type="array|object" name="data">
Data source for the row. **Important**: This parameter is the original data source object that is used for the row. If you are using objects, then `data` is an object - if you are using arrays, then `data` is an array. Thus how you obtain the data from this parameter will depend on how the DataTable is configured.
</parameter>
<parameter type="integer" name="displayNum">
Row number in the current page of displayed rows.
</parameter>
<parameter type="integer" name="displayIndex">
Row number in the current search set of data (i.e. over all available pages).
</parameter>
<parameter type="integer" name="dataIndex">
DataTables' internal index for the row - see `dt-api row().index()`.
</parameter>
<scope>HTML table element</scope>
</type>
<description>
This callback allows you to 'post process' each row after it have been generated for each table draw, but _before_ it is rendered into the document. This means that the contents of the row might not have dimensions (`$().width()` for example) if it is not already in the document.
This function might be used for setting the row class name or otherwise manipulating the row's `-tag tr` element (although note that `dt-init createdRow` can often be more efficient).
</description>
<example title="Highlight cells based on their content (object data source)"><![CDATA[
$('#example').dataTable( {
"rowCallback": function( row, data ) {
if ( data.grade == "A" ) {
$('td:eq(4)', row).html( '<b>A</b>' );
}
}
} );
]]></example>
<example title="Highlight cells based on their content (array data source)"><![CDATA[
$('#example').dataTable( {
"rowCallback": function( row, data ) {
if ( data[4] == "A" ) {
$('td:eq(4)', row).html( '<b>A</b>' );
}
}
} );
]]></example>
<related type="option">drawCallback</related>
<related type="option">createdRow</related>
</dt-option>
|