API

DataTables has an extensive API which can be used to access the data contained in a table and otherwise manipulate the table after the table initialisation has completed. The DataTables API is designed to reflect the structure of the data in the table and how you will typically interact with the table through the API. It can also be extended by the extensions and plug-ins providing additional features and operations.

The API can be accessed through the following methods:

  • $( selector ).DataTable();
  • $( selector ).dataTable().api();
  • new $.fn.dataTable.Api( selector );

The result from each is an instance of the DataTables API object which has the tables found by the selector in its context. 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 jQuery object.

For general information on how the DataTables API operates, including its chaining, how to work with multiple tables and definitions of the terminology used in this reference, please prefer to the API manual.

Library Name Summary
DataTables - Core

$()

Perform a jQuery selection action on the full table.

DataTables - Core

ajax.json()

Get the latest JSON data obtained from the last Ajax request DataTables made

DataTables - Core

ajax.params()

Get the data submitted by DataTables to the server in the last Ajax request

DataTables - Core

ajax.reload()

Reload the table data from the Ajax data source

DataTables - Core

ajax.url().load()

Load data from the newly set data source URL

DataTables - Core

ajax.url()

Get / set the URL that DataTables uses to Ajax fetch data

DataTables - Core

ajax

Namespace for Ajax methods

DataTables - Core

clear()

Clear the table of all data.

DataTables - Core

data()

Get the data for the whole table.

DataTables - Core

destroy()

Destroy the DataTables in the current context.

DataTables - Core

draw()

Redraw the table.

DataTables - Core

i18n()

Internationalisation token lookup.

DataTables - Core

init()

Get the initialisation options used for the table.

DataTables - Core

off()

Table events removal.

DataTables - Core

on()

Table events listener.

DataTables - Core

one()

Listen for a table event once and then remove the listener.

DataTables - Core

order()

Get / set the ordering applied to the table.

DataTables - Core

order.fixed()

Get / set the fixed ordering applied to the table.

DataTables - Core

order.listener()

Add an ordering listener to an element, for a given column.

DataTables - Core

page()

Get / set the current page of the table.

DataTables - Core

page.info()

Get paging information about the table

DataTables - Core

page.len()

Get / set the table's page length.

DataTables - Core

search()

Search for data in the table.

DataTables - Core

settings()

Obtain the table's settings object

DataTables - Core

state()

Get the last saved state of the table

DataTables - Core

state.clear()

Clear the saved state of the table.

DataTables - Core

state.loaded()

Get the table state that was loaded during initialisation.

DataTables - Core

state.save()

Trigger a state save.

DataTables - Cells

cell().cache()

Get the DataTables cached data for the selected cell

DataTables - Cells

cell().data()

Get / set data for the selected cell

DataTables - Cells

cell().index()

Get index information about the selected cell

DataTables - Cells

cell().invalidate()

Invalidate the data held in DataTables for the selected cells

DataTables - Cells

cell().node()

Get the DOM element for the selected cell

DataTables - Cells

cell().render()

Get rendered data for a cell

DataTables - Cells

cell()

Select a single cell from a table.

DataTables - Cells

cells().cache()

Get the DataTables cached data for the selected cells

DataTables - Cells

cells().data()

Get data for the selected cells

DataTables - Cells

cells().every()

Iterate over each selected cell, with the function context set to be the cell in question.

DataTables - Cells

cells().indexes()

Get index information about the selected cells

DataTables - Cells

cells().invalidate()

Invalidate the data held in DataTables for the selected cells

DataTables - Cells

cells().nodes()

Get the DOM elements for the selected cells

DataTables - Cells

cells().render()

Get rendered data for a collection of cells

DataTables - Cells

cells()

Select multiple cells from a table.

DataTables - Columns

column().cache()

Get the DataTables cached data for the selected column.

DataTables - Columns

column().data()

Get the data for the cells in the selected column.

DataTables - Columns

column().dataSrc()

Get the data source property for the selected column.

DataTables - Columns

column().footer()

Get the footer node for the selected column.

DataTables - Columns

column().header()

Get the header node for the selected column.

DataTables - Columns

column().index()

Get the column index of the selected column.

DataTables - Columns

column().nodes()

Get the cell nodes for the selected column.

DataTables - Columns

column().order()

Order the table by the selected column.

DataTables - Columns

column().search()

Search for data in the selected column.

DataTables - Columns

column().visible()

Get / set the visibility of a single selected column.

DataTables - Columns

column()

Select a single column from a table.

DataTables - Columns

column.index()

Convert between column index formats

DataTables - Columns

columns().cache()

Get the DataTables cached data for the selected columns.

DataTables - Columns

columns().data()

Get the data for the cells in the selected columns.

DataTables - Columns

columns().dataSrc()

Get the data source property for the selected columns.

DataTables - Columns

columns().every()

Iterate over each selected column, with the function context set to be the column in question.

DataTables - Columns

columns().footer()

Get the footer nodes for the selected columns.

DataTables - Columns

columns().header()

Get the header node for the selected columns.

DataTables - Columns

columns().indexes()

Get the column indexes of the selected columns.

DataTables - Columns

columns().nodes()

Get the cell nodes for the selected columns.

DataTables - Columns

columns().order()

Order the table by the selected columns.

DataTables - Columns

columns().search()

Search for data in the selected columns.

DataTables - Columns

columns().visible()

Get / set the visibility of the selected columns.

DataTables - Columns

columns()

Select multiple columns from a table.

DataTables - Columns

columns.adjust()

Recalculate the column widths

DataTables - Rows

row().cache()

Get the DataTables cached data for the selected row.

DataTables - Rows

row().child().hide()

Hide child rows after creating new child rows

DataTables - Rows

row().child().remove()

Destroy child row(s) for the selected parent row

DataTables - Rows

row().child().show()

Make newly defined child rows visible

DataTables - Rows

row().child()

Get / set the child rows of the selected main table row

DataTables - Rows

row().child.hide()

Hide the child row(s) of a parent row

DataTables - Rows

row().child.isShown()

Check if the child rows of a parent row are visible

DataTables - Rows

row().child.remove()

Destroy child row(s) for the selected parent row

DataTables - Rows

row().child.show()

Make the child row(s) of a parent row visible

DataTables - Rows

row().child

Row child method namespace

DataTables - Rows

row().data()

Get / set the data for the selected row.

DataTables - Rows

row().id()

Get the id of the selected row.

DataTables - Rows

row().index()

Get the row index of the selected row.

DataTables - Rows

row().invalidate()

Invalidate the data held in DataTables for the selected row

DataTables - Rows

row().node()

Get the row TR node for the selected row.

DataTables - Rows

row().remove()

Delete the selected row from the DataTable.

DataTables - Rows

row()

Select a single row from a table.

DataTables - Rows

row.add()

Add a new row to the table.

DataTables - Rows

rows().cache()

Get the DataTables cached data for the selected rows.

DataTables - Rows

rows().data()

Get the data for the selected rows.

DataTables - Rows

rows().every()

Iterate over each selected row, with the function context set to be the row in question.

DataTables - Rows

rows().ids()

Get the ids of the selected rows.

DataTables - Rows

rows().indexes()

Get the row indexes of the selected rows.

DataTables - Rows

rows().invalidate()

Invalidate the data held in DataTables for the selected rows

DataTables - Rows

rows().nodes()

Get the row TR nodes for the selected rows.

DataTables - Rows

rows().remove()

Delete the selected rows from the DataTable.

DataTables - Rows

rows()

Select multiple rows from a table.

DataTables - Rows

rows.add()

Add multiple new rows to the table.

DataTables - Tables

table().body()

Get the tbody node for the table in the API's context

DataTables - Tables

table().container()

Get the div container node for the table in the API's context

DataTables - Tables

table().footer()

Get the tfoot node for the table in the API's context

DataTables - Tables

table().header()

Get the thead node for the table in the API's context

DataTables - Tables

table().node()

Get the table node for the table in the API's context

DataTables - Tables

table()

Select a table based on a selector from the API's context

DataTables - Tables

tables().body()

Get the tbody nodes for the tables in the API's context

DataTables - Tables

tables().containers()

Get the div container nodes for the tables in the API's context

DataTables - Tables

tables().footer()

Get the tfoot nodes for the tables in the API's context

DataTables - Tables

tables().header()

Get the thead nodes for the tables in the API's context

DataTables - Tables

tables().nodes()

Get the table nodes for the tables in the API's context

DataTables - Tables

tables()

Select tables based on a selector from the API's context

DataTables - Utility

any()

Determine if there are any entries in the result set

DataTables - Utility

concat()

Combine multiple API instances to create a single new instance.

DataTables - Utility

count()

Get the number of elements that are contained in an API instance

DataTables - Utility

each()

Iterate over the contents of the API result set.

DataTables - Utility

eq()

Reduce an Api instance to a single context and result set.

DataTables - Utility

filter()

Create a new API instance with all elements from the result set which pass a given test.

DataTables - Utility

flatten()

Flatten a 2D array structured API instance to a 1D array structure.

DataTables - Utility

indexOf()

Find the first instance of a value in the API instance's result set.

DataTables - Utility

iterator()

Iterate over a result set of table, row, column or cell indexes

DataTables - Utility

join()

Join the elements in the result set into a string.

DataTables - Utility

lastIndexOf()

Find the last instance of a value in the API instance's result set.

DataTables - Utility

length

Number of elements in an API instance's result set.

DataTables - Utility

map()

Create a new API instance with the result set defined by the values returned from the callback function.

DataTables - Utility

pluck()

Create a new API instance with the value of a property from the objects in the current result set.

DataTables - Utility

pop()

Remove the last item from an API instance's result set.

DataTables - Utility

push()

Add one or more items to the end of an API instance's result set.

DataTables - Utility

reduce()

Apply a callback function against and accumulator and each element in the Api's result set (left-to-right).

DataTables - Utility

reduceRight()

Apply a callback function against and accumulator and each element in the Api's result set (right-to-left).

DataTables - Utility

reverse()

Reverse the result set of the API instance.

DataTables - Utility

shift()

Remove the first item from an API instance's result set.

DataTables - Utility

sort()

Sort the elements of the API instance's result set.

DataTables - Utility

splice()

Modify the contents of an Api instance's result set, adding or removing items from it as required.

DataTables - Utility

to$()

Convert the API instance to a jQuery object, with the objects from the instance's result set in the jQuery result set.

DataTables - Utility

toArray()

Create a native Javascript array object from an API instance.

DataTables - Utility

toJQuery()

Convert the API instance to a jQuery object, with the objects from the instance's result set in the jQuery result set.

DataTables - Utility

unique()

Create a new API instance containing only the unique items from a the elements in an instance's result set.

DataTables - Utility

unshift()

Add one or more items to the start of an API instance's result set.

DataTables - Static

$.fn.dataTable.isDataTable()

Check is a table node is a DataTable or not

DataTables - Static

$.fn.dataTable.tables()

Get all DataTables on the page

DataTables - Static

$.fn.dataTable.util.escapeRegex()

Escape special characters in a regular expression string

DataTables - Static

$.fn.dataTable.util.throttle()

Throttle the calls to a method to reduce call frequency

DataTables - Static

$.fn.dataTable.versionCheck()

Version number compatibility check function

Buttons

button().action()

Get / set the action function for the selected button

Buttons

button().active()

Get / set the active state of the selected button

Buttons

button().add()

Create a new button and add it to the document

Buttons

button().disable()

Disable the selected buttons

Buttons

button().enable()

Enable / disable the selected button

Buttons

button().node()

Get the button node for the selected button

Buttons

button().remove()

Remove and delete the selected button

Buttons

button().text()

Get / set the text for the selected button

Buttons

button().trigger()

Trigger the action of the selected button

Buttons

button()

Select a single button

Buttons

buttons().action()

Get / set the action functions for the selected buttons

Buttons

buttons().active()

Set the active state for the selected buttons

Buttons

buttons().container()

Get the container element for a single Buttons instance

Buttons

buttons().containers()

Get the container elements for one or more button instances

Buttons

buttons().destroy()

Destroy one or more button instances and remove from the document

Buttons

buttons().disable()

Disable the selected buttons

Buttons

buttons().enable()

Enable / disable the selected buttons

Buttons

buttons().nodes()

Get the button nodes for the selected buttons

Buttons

buttons().remove()

Remove and delete the selected buttons

Buttons

buttons().text()

Get / set the text for the selected buttons

Buttons

buttons().trigger()

Trigger the action of the selected buttons

Buttons

buttons()

Select one or more buttons

Buttons

buttons.exportData()

Obtain data from the DataTable that is suitable for exporting

Buttons

buttons.info()

Display and hide an information for the end user in a modal box

Buttons

buttons.resize()

Resize all Flash buttons once a table has been made visible

ColReorder

colReorder.order()

Get / set column order

ColReorder

colReorder.reset()

Restore the loaded column order

ColReorder

colReorder.transpose()

Convert one or more column indexes to and from current and original indexes

Editor

cell().edit()

Edit a cell with inline or bubble editing

Editor

cells().edit()

Edit cells with bubble editing

Editor

editor()

Get the Editor instance associated with this table.

Editor

file()

Get information about a previously uploaded file

Editor

files()

Get information about multiple uploaded files

Editor

row().delete()

Delete an existing row

Editor

row().edit()

Edit an existing row

Editor

row.create()

Create a new row

Editor

rows().delete()

Delete multiple existing rows

Editor

rows().edit()

Edit multiple existing rows

FixedColumns

fixedColumns().cellIndex()

Get the cell index of a cell in a fixed column

FixedColumns

fixedColumns().relayout()

Redraw the fixed columns based on new table size

FixedColumns

fixedColumns().rowIndex()

Get the row index of a row in a fixed column

FixedColumns

fixedColumns().update()

Update the data shown in the FixedColumns

FixedColumns

fixedColumns()

Namespace for FixedColumns methods

FixedColumns

rows().recalcHeight()

Recalculate the height of one or more rows after a data change

FixedHeader

fixedHeader.adjust()

Recalculate the position of the table and redraw the fixed elements

FixedHeader

fixedHeader.disable()

Disable the fixed elements

FixedHeader

fixedHeader.enable()

Enable / disable the fixed elements

FixedHeader

fixedHeader.footerOffset()

Get / set the fixed footer's offset

FixedHeader

fixedHeader.headerOffset()

Get / set the fixed header's offset

KeyTable

cell().focus()

Focus on a cell

KeyTable

cell.blur()

Blur focus from the table

KeyTable

keys.disable()

Disable KeyTable's interactions (mouse and keyboard)

KeyTable

keys.enable()

Enable or disable KeyTable's interactions (mouse and keyboard)

Responsive

responsive.index()

Obtain the cell index from a li details element

Responsive

responsive.rebuild()

Recalculate the column breakpoints based on the class information of the column header cells

Responsive

responsive.recalc()

Recalculate the widths used by responsive after a change in the display

Scroller

row().scrollTo()

Scroll to a specific row

Scroller

scroller.measure()

Recalculate the cached measurements that Scroller uses

Select

cell().deselect()

Deselect a single cell

Select

cell().select()

Select a single cell

Select

cells().deselect()

Deselect cells

Select

cells().select()

Select cells

Select

column().deselect()

Deselect a single column

Select

column().select()

Select a single column

Select

columns().deselect()

Deselect columns

Select

columns().select()

Select columns

Select

row().deselect()

Deselect a single row

Select

row().select()

Select a single row

Select

rows().deselect()

Deselect rows

Select

rows().select()

Select rows

Select

select()

Initialise Select from outside of the constructor

Select

select.blurable()

Get / set the blurable state of the table's item selection options

Select

select.info()

Get / set the information summary display state

Select

select.items()

Get / set the items that Select will select based on user interaction (rows, columns or cells)

Select

select.selector()

Get / set the item selector for mouse event capture

Select

select.style()

Get / set the style by which the end user can select items in the table