HTML (DOM) sourced data
Basic example of a datatable with HTML (DOM)sourced data. The foundation for DataTables is progressive enhancement, so it is very adept at reading table information directly from the DOM. This example shows how easy it is to add searching, ordering and paging to your HTML table by simply running DataTables with basic configuration on it.
Javascript sourced data
At times you will wish to be able to create a table from dynamic information passed directly to DataTables, rather than having it read from the document. This is achieved using the dataoption in the initialisation object, passing in an arrayof data to be used. This examples shows the element being added by Javascript and then initialising the DataTable with a set of data from a Javascript array.
Ajax sourced data
DataTables has the ability to read data from virtually any JSONdata source that can be obtained by Ajax. This can be done, in its most simple form, by setting the ajaxoption to the address of the JSONdata source. The example below shows DataTables loading data for a table from arraysas the data source (object parameters can also be used through the columns.dataoption).
Nested object data
The information read from an Ajaxdata source can be arbitrarily complex, but still be displayed by DataTables through the columns.dataoption, which is particularly useful for working with JSONfeeds in an already defined format. The columns.dataoption has the ability to read information not only from objects, but also from arrays using the same dotted object syntax as for objects.
Generated content for a column
In some tables you might wish to have some content generated automatically. This examples shows the use of columns.defaultContentto create a button element in the last column of the table. A simple jQuery clickevent listener is used to watch for clicks on the row, and when activated uses the row().data()method to get the data for the row and show a bit of information about it in an alert box.