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:

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

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

Namespace for Ajax methods

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()

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

DataTables - Core

ajax.url().load()

Load data from the newly set data source URL

DataTables - Core

clear()

Clear the table of all data.

DataTables - Core

column().init()

Get the initialisation options for a column.

DataTables - Core

column().search.fixed()

Get / set a named search to apply to a column.

DataTables - Core

columns().init()

Get the initialisation options for the selected columns.

DataTables - Core

columns().search.fixed()

Get / set a named search to apply to a column.

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

processing()

Set the processing indicator state for the DataTable.

DataTables - Core

search()

Search for data in the table.

DataTables - Core

search.fixed()

Get / set a named search to apply to a table.

DataTables - Core

settings()

Obtain the table's settings object

DataTables - Core

state()

Get / set the 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 - Core

trigger()

Trigger an event.

DataTables - Cells

cell()

Select a single cell from a table.

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

cells()

Select multiple cells 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 - Columns

column()

Select a single column 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().orderable()

Get information about the orderable status of a column.

DataTables - Columns

column().render()

Get rendered data for a column

DataTables - Columns

column().search()

Search for data in the selected column.

DataTables - Columns

column().title()

Get / set the title for a column.

DataTables - Columns

column().type()

Get a column's data type.

DataTables - Columns

column().visible()

Get / set the visibility of a single selected column.

DataTables - Columns

column().width()

Get the width of a column.

DataTables - Columns

column.index()

Convert between column index formats

DataTables - Columns

columns()

Select multiple columns from a table.

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().orderable()

Get information about the orderable status of the selected columns.

DataTables - Columns

columns().render()

Get rendered data for a collection of columns

DataTables - Columns

columns().search()

Search for data in the selected columns.

DataTables - Columns

columns().titles()

Get / set the title for multiple columns.

DataTables - Columns

columns().types()

Get the data types for selected columns.

DataTables - Columns

columns().visible()

Get / set the visibility of the selected columns.

DataTables - Columns

columns().widths()

Get the widths of a group of columns.

DataTables - Columns

columns.adjust()

Recalculate the column widths

DataTables - Rows

row()

Select a single row from a table.

DataTables - Rows

row().cache()

Get the DataTables cached data for the selected row.

DataTables - Rows

row().child

Row child method namespace

DataTables - Rows

row().child()

Get / set the child rows of the selected main table 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.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().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.add()

Add a new row to the table.

DataTables - Rows

rows()

Select multiple rows from a 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.add()

Add multiple new rows to the table.

DataTables - Tables

caption()

Get / set the table's caption

DataTables - Tables

caption.node()

Get the table's caption element

DataTables - Tables

table()

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

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().footer.structure()

Get a Javascript representation of the table footer structure

DataTables - Tables

table().header()

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

DataTables - Tables

table().header.structure()

Get a Javascript representation of the table header structure

DataTables - Tables

table().node()

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

DataTables - Tables

tables()

Select tables 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 - Utility

any()

Determine if there are any entries in the result set

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

error()

Trigger an error message.

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

get()

Get the underlying data from a DataTable instance

DataTables - Utility

includes()

Determine if an API result set contains a given value.

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

ready()

Determine is a DataTable is ready.

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

slice()

Create an independent copy of the API instance.

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 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

DataTable.datetime()

Register a date / time format for DataTables to use

DataTables - Static

DataTable.feature.register()

Create a new feature that can be used for layout

DataTables - Static

DataTable.isDataTable()

Check is a table node is a DataTable or not

DataTables - Static

DataTable.tables()

Get all DataTables on the page

DataTables - Static

DataTable.type()

Get / set details of a data type

DataTables - Static

DataTable.types()

Get a list of the data types registered

DataTables - Static

DataTable.util.debounce()

Wait for a timeout before calling a function

DataTables - Static

DataTable.util.diacritics()

Normalise diacritic characters in a string.

DataTables - Static

DataTable.util.escapeHtml()

Escape HTML entities to make a user input string safe

DataTables - Static

DataTable.util.escapeRegex()

Escape special characters in a regular expression string

DataTables - Static

DataTable.util.get()

Create a read function from a descriptor

DataTables - Static

DataTable.util.set()

Create a write function from a descriptor

DataTables - Static

DataTable.util.stripHtml()

Remove HTML from a string

DataTables - Static

DataTable.util.throttle()

Throttle the calls to a method to reduce call frequency

DataTables - Static

DataTable.util.unique()

Get all unique items from an array

DataTables - Static

DataTable.versionCheck()

Version number compatibility check function

AutoFill

autoFill().disable()

Disable AutoFill's interactions

AutoFill

autoFill().enable()

Enable or disable AutoFill's interactions

AutoFill

autoFill().enabled()

Determine if AutoFill is enabled or disabled

Buttons

DataTable.fileSave()

Save a file that has been created on the client-side

Buttons

button()

Select a single button

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().collectionRebuild()

Rebuild a buttons collection

Buttons

button().disable()

Disable the selected button

Buttons

button().enable()

Enable / disable the selected button

Buttons

button().index()

Get the index of a node

Buttons

button().node()

Get the button node for the selected button

Buttons

button().popover()

Show popover box for a button, allowing extra user input

Buttons

button().processing()

Get / set the processing state for a 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

buttons()

Select one or more buttons

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().collectionRebuild()

Rebuild a buttons collection

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().processing()

Set the processing state for multiple 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.exportData()

Obtain data from the DataTable that is suitable for exporting

Buttons

buttons.exportInfo()

Get export meta information that is common to many different button types

Buttons

buttons.info()

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

ColReorder

colReorder.disable()

Disable ColReorder's interactions

ColReorder

colReorder.enable()

Enable or disable ColReorder's interactions

ColReorder

colReorder.move()

Programmatically move columns

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

FixedColumns

fixedColumns()

Namespace for FixedColumns methods

FixedColumns

fixedColumns().end()

Get / set the number of columns fixed at the end of a table

FixedColumns

fixedColumns().left()

Get / set the number of fixed columns on the left side of a table

FixedColumns

fixedColumns().right()

Get / set the number of fixed columns on the right side of a table

FixedColumns

fixedColumns().start()

Get / set the number of columns fixed at the start of a table

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.enabled()

Get the current enabled status

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)

KeyTable

keys.enabled()

Determine the KeyTable enabled state for a table

KeyTable

keys.move()

Move the focus to an adjacent cell

Responsive

column().responsiveHidden()

Get the responsive visibility state of a column in the table

Responsive

columns().responsiveHidden()

Get the responsive visibility state of columns in the table

Responsive

responsive.hasHidden()

Determine if Responsive has hidden any columns in the table

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

RowGroup

rowGroup().dataSrc()

Get / set the data source for the row grouping

RowGroup

rowGroup().disable()

Disable RowGroup's interaction with the table

RowGroup

rowGroup().enable()

Enable or disable RowGroup's interaction with the table

RowGroup

rowGroup().enabled()

Determine if RowGroup is enabled on a table

RowReorder

rowReorder.disable()

Disable the user's ability to reorder rows.

RowReorder

rowReorder.enable()

Enable / disable the user's ability to reorder rows.

Scroller

row().scrollTo()

Scroll to a specific row

Scroller

scroller.measure()

Recalculate the cached measurements that Scroller uses

Scroller

scroller.page()

Get information about the rows that are currently being displayed

Scroller

scroller.toPosition()

Scroll to a specific row display index

SearchBuilder

searchBuilder.container()

Returns the node of the SearchBuilder container.

SearchBuilder

searchBuilder.getDetails()

Get the details of the current search setup

SearchBuilder

searchBuilder.rebuild()

Rebuild the search to a given state

SearchPanes

searchPanes.clearSelections()

Clears the selections in all of the panes

SearchPanes

searchPanes.container()

Returns the node of the panes container.

SearchPanes

searchPanes.rebuildPane()

Rebuild the pane, regathering options from the table.

SearchPanes

searchPanes.resizePanes()

Resize all of the panes to fill the SearchPanes container appropriately.

Select

cell().deselect()

Deselect a single cell

Select

cell().select()

Select a single cell

Select

cell().selected()

Determine if a cell has been selected

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

column().selected()

Determine if a column has been selected

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

row().selected()

Determine if a row has been selected

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

Select

select.toggleable()

Get / set the behaviour if items can be deselected when a selected item is clicked on

StateRestore

stateRestore.activeStates()

Get the details of all of the currently active states

StateRestore

stateRestore.state()

Get a state from StateRestore

StateRestore

stateRestore.state().load()

Load a state from StateRestore into the table

StateRestore

stateRestore.state().remove()

Remove a state from StateRestore

StateRestore

stateRestore.state().rename()

Rename a state from StateRestore

StateRestore

stateRestore.state().save()

Save a state from StateRestore

StateRestore

stateRestore.state.add()

Create a new state

StateRestore

stateRestore.states()

Get states from StateRestore

StateRestore

stateRestore.states().remove()

Remove states from StateRestore