File: DataTables.Api.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 (69 lines) | stat: -rw-r--r-- 2,798 bytes parent folder | download | duplicates (3)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?xml version="1.0" encoding="UTF-8" ?>
<dt-type group="dt">
	<name>DataTables.Api</name>
	<summary>DataTables API object instance</summary>

	<description>
	<![CDATA[

The DataTables API provides the ability to programmatically control one or more DataTable tables through the extensive array of methods that it implements. Many methods the API implements return an API instance themselves, providing the ability to [chain](http://en.wikipedia.org/wiki/Method_chaining) methods, thus allowing the API to be both compact and very expressive. As such, we define this `dt-type DataTables.Api` data type to be clear when a method provides an API instance as its return value.


## API structure

The API object is _array-like_, in that it has a `length` property, elements in its result set can be accessed using Javascript array notation (`[]`) and it provides many (although not all) of the same methods as an `dt-type array` (for example `dt-api push()` and `dt-api indexOf()`).


## Accessing the API

New API instances can be created in one of three ways:

* `$( selector ).DataTable();` - DataTables constructor
* `$( selector ).dataTable().api();` - DataTables jQuery constructor
* `new $.fn.dataTable.Api( selector );` - Direct initialisation

The result from each is an instance of the DataTables API object which has the tables found by the selector in its context. In all three cases `selector` is a [jQuery selector](http://api.jquery.com/category/selectors/).

It is important to note the difference between `$( selector ).DataTable()` and `$( selector ).dataTable()`. The former returns a DataTables API instance, while the latter returns a `dt-type jQuery` object. An `api()` method is added to the jQuery object so you can easily access the API, but the jQuery object can be useful for manipulating the table node, as you would with any other jQuery instance (such as using `addClass()` etc).

###### $( selector ).DataTable(); example

```js
var table = $('#myTable').DataTable();

// Search for a data point
table.search( 'Fiona' ).draw();
```


###### $( selector ).dataTable(); example

```js
var table = $('#myTable').dataTable().api();

// Jump to the next page of data
table.page('next').draw(false);
```


###### new $.fn.dataTable.Api( selector );

```js
var table = new $.fn.dataTable.Api( '#myTable' );

// Get data from the first row
var data = table.rows().data()[0]; // same as row(0).data()
```


## Further information

Use the following resources to explore the DataTables API further:

* [API manual](/manual/api) - detailed usage and explanation of the API terminology
* [API reference](/reference/api) - list of all API methods available
* [API plug-ins](/plug-ins/api) - community provided plug-ins to extend the API's capabilities

	]]>
	</description>
</dt-type>