File: rowCallback.xml

package info (click to toggle)
datatables.js 1.10.21%2Bdfsg-2%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 22,604 kB
  • sloc: javascript: 64,254; xml: 10,441; php: 4,623; sh: 523; makefile: 21
file content (55 lines) | stat: -rw-r--r-- 2,319 bytes parent folder | download | duplicates (4)
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>