File: lastIndexOf%28%29.xml

package info (click to toggle)
datatables.js 1.11.5%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 22,848 kB
  • sloc: javascript: 65,075; xml: 10,712; php: 4,741; sh: 544; makefile: 18
file content (41 lines) | stat: -rw-r--r-- 1,993 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
<?xml version="1.0" encoding="UTF-8" ?>
<dt-api group="utility">
	<name>lastIndexOf()</name>
	<summary>Find the last instance of a value in the API instance's result set.</summary>
	<since>1.10</since>

	<type type="function">
		<signature>lastIndexOf( value )</signature>
		<description>Find the last instance of a value in the API instance's result set.</description>
		<parameter type="*" name="value">
			Value to find in the instance's result set.
		</parameter>
		<returns type="integer">The index of the item in the result set, or -1 if not found.</returns>
	</type>

	<description>
		It is often useful to know if a value is in a result set, and if so, which position it holds. This method provides exactly that ability, searching for the value given, starting from the last item in the instance's result set and working back through the result set (see `dt-api indexOf()` to search for the first instance of a value) and giving its position in the result set.

		This method makes use of the fact that DataTables API objects are "array like", in that they inherit a lot of the abilities and methods of the Javascript `Array` type.

		In this case, this method is a proxy for the Javascript `Array.prototype.lastIndexOf` method and is provided as a utility method for the DataTables API. For more information about the original method, please refer to the [Mozilla MDN documentation for `lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf). In browsers which do not support `lastIndexOf` natively, a polyfill is provided to allow this DataTables method to operate as expected.
	</description>

	<example title="Find the last index of an item in a column of data"><![CDATA[
var table = $('#example').DataTable();

var index = table
	.column( 0 )
	.data()
	.lastIndexOf( 21 );

if ( index < 0 ) {
	alert( '21 was not found in the result set' );
}
else {
	alert( '21 was found at index: '+index );
}

]]></example>

</dt-api>