Advanced Datatable
DOM / jQuery events
Events assigned to the table can be exceptionally useful for user interaction, however you must be aware that DataTables will add and remove rows from the DOM as they are needed (i.e. when paging only the visible elements are actually available in the DOM). As such, this can lead to the odd hiccup when working with events.
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|
Airi Satou | Accountant | Tokyo | 33 | 2008/11/28 | $162,700 |
Ashton Cox | Junior Technical Author | San Francisco | 66 | 2009/01/12 | $86,000 |
Bradley Greer | Software Engineer | London | 41 | 2012/10/13 | $132,000 |
Brielle Williamson | Integration Specialist | New York | 61 | 2012/12/02 | $372,000 |
Cedric Kelly | Senior Javascript Developer | Edinburgh | 22 | 2012/03/29 | $433,060 |
Charde Marshall | Regional Director | San Francisco | 36 | 2008/10/16 | $470,600 |
Colleen Hurst | Javascript Developer | San Francisco | 39 | 2009/09/15 | $205,500 |
Dai Rios | Personnel Lead | Edinburgh | 35 | 2012/09/26 | $217,500 |
Garrett Winters | Accountant | Tokyo | 63 | 2011/07/25 | $170,750 |
Gloria Little | Systems Administrator | New York | 59 | 2009/04/10 | $237,500 |
Name | Position | Office | Age | Start date | Salary |
Column rendering
Each column has an optional rendering control called columns.render which can be used to process the content of each cell before the data is used. columns.render has a wide array of options available to it for rendering different types of data orthogonally (ordering, searching, display etc), but it can be used very simply to manipulate the content of a cell, as shown here.
Name | Position | Office | Start date | Salary |
---|---|---|---|---|
Airi Satou (33) | Accountant | Tokyo | 2008/11/28 | $162,700 |
Ashton Cox (66) | Junior Technical Author | San Francisco | 2009/01/12 | $86,000 |
Bradley Greer (41) | Software Engineer | London | 2012/10/13 | $132,000 |
Brielle Williamson (61) | Integration Specialist | New York | 2012/12/02 | $372,000 |
Cedric Kelly (22) | Senior Javascript Developer | Edinburgh | 2012/03/29 | $433,060 |
Charde Marshall (36) | Regional Director | San Francisco | 2008/10/16 | $470,600 |
Colleen Hurst (39) | Javascript Developer | San Francisco | 2009/09/15 | $205,500 |
Dai Rios (35) | Personnel Lead | Edinburgh | 2012/09/26 | $217,500 |
Garrett Winters (63) | Accountant | Tokyo | 2011/07/25 | $170,750 |
Gloria Little (59) | Systems Administrator | New York | 2009/04/10 | $237,500 |
Name | Position | Office | Start date | Salary |
Read HTML to data objects
When DataTables reads the table content from an HTML table (rather than an Ajax or Javascript data source), by default it will read the information in the table into an array that DataTables stores internally. Each array element represents a column.
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|
Airi Satou | Accountant | Tokyo | 33 | 2008/11/28 | $162,700 |
Ashton Cox | Junior Technical Author | San Francisco | 66 | 2009/01/12 | $86,000 |
Bradley Greer | Software Engineer | London | 41 | 2012/10/13 | $132,000 |
Brielle Williamson | Integration Specialist | New York | 61 | 2012/12/02 | $372,000 |
Cedric Kelly | Senior Javascript Developer | Edinburgh | 22 | 2012/03/29 | $433,060 |
Charde Marshall | Regional Director | San Francisco | 36 | 2008/10/16 | $470,600 |
Colleen Hurst | Javascript Developer | San Francisco | 39 | 2009/09/15 | $205,500 |
Dai Rios | Personnel Lead | Edinburgh | 35 | 2012/09/26 | $217,500 |
Garrett Winters | Accountant | Tokyo | 63 | 2011/07/25 | $170,750 |
Gloria Little | Systems Administrator | New York | 59 | 2009/04/10 | $237,500 |
Name | Position | Office | Age | Start date | Salary |
Row created callback
The following example shows how a callback function can be used to format a particular row at draw time. For each row that is generated for display, the createdRow function is called once and once only. It is passed the create row node which can then be modified.
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|
Airi Satou | Accountant | Tokyo | 33 | 2008/11/28 | $162,700 |
Ashton Cox | Junior Technical Author | San Francisco | 66 | 2009/01/12 | $86,000 |
Bradley Greer | Software Engineer | London | 41 | 2012/10/13 | $132,000 |
Brielle Williamson | Integration Specialist | New York | 61 | 2012/12/02 | $372,000 |
Cedric Kelly | Senior Javascript Developer | Edinburgh | 22 | 2012/03/29 | $433,060 |
Charde Marshall | Regional Director | San Francisco | 36 | 2008/10/16 | $470,600 |
Colleen Hurst | Javascript Developer | San Francisco | 39 | 2009/09/15 | $205,500 |
Dai Rios | Personnel Lead | Edinburgh | 35 | 2012/09/26 | $217,500 |
Garrett Winters | Accountant | Tokyo | 63 | 2011/07/25 | $170,750 |
Gloria Little | Systems Administrator | New York | 59 | 2009/04/10 | $237,500 |
Name | Position | Office | Age | Start date | Salary |