File: createdRow.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 (44 lines) | stat: -rw-r--r-- 1,696 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
<?xml version="1.0" encoding="UTF-8" ?>
<dt-option group="callback">
	<name>createdRow</name>
	<summary>Callback for whenever a TR element is created for the table's body.</summary>
	<since>1.10</since>

	<type type="function">
		<signature>createdRow( row, data, dataIndex, cells )</signature>
		<parameter type="node" name="row">
			`tag TR` row element that has just been created
		</parameter>
		<parameter type="array|object" name="data">
			Raw data source (array or object) for this row
		</parameter>
		<parameter type="integer" name="dataIndex">
			The index of the row in DataTables' internal storage.
		</parameter>
		<parameter type="node[]" name="cells" since="1.10.17">
			The cells for the column.
		</parameter>
		<scope>HTML table element</scope>
	</type>

	<description>
		This callback is executed when a `tag TR` element is created (and all `tag TD` child elements have been inserted), or registered if using a DOM source, allowing manipulation of the `tag TR` element.

		This is particularly useful when using deferred rendering (`dt-init deferRender`) or server-side processing (`dt-init serverSide`) so you can add events, class name information or otherwise format the row when it is created.
	</description>

	<example title="Add a class to the row, conditionally based on the row's data"><![CDATA[
$('#example').dataTable( {
  "createdRow": function( row, data, dataIndex ) {
    if ( data[4] == "A" ) {
      $(row).addClass( 'important' );
    }
  }
} );
]]></example>

	<related type="option">data</related>
	<related type="option">deferRender</related>
	<related type="option">serverSide</related>
	<related type="option">columns.createdCell</related>
</dt-option>