0

I am initializing my table with DataTables.js

$('#clients').dataTable();

this is returning the jQuery DOM element, instead of the API.

How do I gain access to the API?

1
  • For the record, I am using DataTables 1.9.4 and jQuery UI 1.9.2 Commented May 12, 2014 at 15:10

1 Answer 1

2

It is only in dataTables 1.10.x, using the constructor .DataTable(), that you receive an fully qualified API-object.

In dataTables v 1.9.4 (versions below 1.10.x) the returned jQuery object is extended with the DataTables API methods.

When you have

var dataTable = $('#clients').dataTable();

you have direct access to the API through the variable dataTable, like dataTable.fnFilter().

The following API methods are directly supported by a 1.9.x dataTables jQuery object :

fnAddData
fnAdjustColumnSizing
fnClearTable
fnClose
fnDeleteRow
fnDestroy
fnDraw
fnFilter
fnGetData
fnGetNodes
fnGetPosition
fnIsOpen
fnOpen
fnPageChange
fnSetColumnVis
fnSettings
fnSort
fnSortListener
fnUpdate
fnVersionCheck

demonstration -> http://jsfiddle.net/L6rJk/

The API in 1.10.x is vastly extended, and is backwards compatible. But most functions and API-references on the newly redesigned homepage http://datatables.net/ are targeting 1.10.x only! To view the old documentation, goto http://legacy.datatables.net/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.