diff --git a/api/average().js b/api/average().js
index 6c2a3f0..8b23963 100644
--- a/api/average().js
+++ b/api/average().js
@@ -1,13 +1,24 @@
/**
- * Average the values in a data set.
+ * It can sometimes be useful to get the average of data in an API result set,
+ * be it from a column, or a collection of cells. This method provides exactly
+ * that ability.
*
* @name average()
- * @summary
+ * @summary Average the values in a data set.
* @author [Allan Jardine](http://sprymedia.co.uk)
* @requires DataTables 1.10+
*
+ * @returns {Number} Calculated average
+ *
* @example
+ * // Average a column
+ * var table = $('#example').DataTable();
* table.column( 3 ).data().average();
+ *
+ * @example
+ * // Average two cells
+ * var table = $('#example').DataTable();
+ * table.cells( 0, [3,4] ).data().average();
*/
jQuery.fn.dataTable.Api.register( 'average()', function () {
diff --git a/api/fnAddDataAndDisplay.js b/api/fnAddDataAndDisplay.js
index cb0cc2a..4441658 100644
--- a/api/fnAddDataAndDisplay.js
+++ b/api/fnAddDataAndDisplay.js
@@ -1,20 +1,25 @@
/**
* Add a new row to the table and display it on the screen by jumping the
* pagination to the required location. This function also returns an object
- * with the added TR element and it's index in aoData such that you could
- * provide an effect (fade for example) to show which row has been added.
- * This function is a drop in replacement for fnAddData with one important
+ * with the added `dt-tag TR` element and it's index in `aoData` such that you
+ * could provide an effect (fade for example) to show which row has been added.
+ *
+ * This function is a drop in replacement for `fnAddData` with one important
* exception, it will only take a 1D array or an object, and not a 2D array
- * (i.e. it will not add multiple rows like fnAddData).
+ * (i.e. it will not add multiple rows like `fnAddData`).
*
* @name fnAddDataAndDisplay
- * @summary
+ * @summary Add data and shift the paging to display it immediately
* @author [Allan Jardine](http://sprymedia.co.uk)
*
+ * @param {data} aData Data to add to the table
+ * @returns {object} Object with `nTr` and `iPos` parameters, where the former
+ * is the added `dt-tag tr` element and the latter is the row's index.
+ *
* @example
* $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- * oTable.fnAddDataAndDisplay( [ 1, 2, 3, 4, 5, ... ] );
+ * var table = $('#example').dataTable();
+ * table.fnAddDataAndDisplay( [ 1, 2, 3, 4, 5, ... ] );
* } );
*/
@@ -45,7 +50,9 @@ jQuery.fn.dataTableExt.oApi.fnAddDataAndDisplay = function ( oSettings, aData )
if( iPos >= 0 )
{
oSettings._iDisplayStart = ( Math.floor(i / oSettings._iDisplayLength) ) * oSettings._iDisplayLength;
- this.oApi._fnCalculateEnd( oSettings );
+ if ( this.oApi._fnCalculateEnd ) {
+ this.oApi._fnCalculateEnd( oSettings );
+ }
}
this.oApi._fnDraw( oSettings );
diff --git a/api/fnAddTr.js b/api/fnAddTr.js
index 0c02ecd..594d8e4 100644
--- a/api/fnAddTr.js
+++ b/api/fnAddTr.js
@@ -1,13 +1,30 @@
/**
- * Take a TR element and add it to a DataTables table. Useful for maintaining
- * custom classes and other attributes.
+ * This method will add an existing `dt-tag tr` element to a DataTable. This can
+ * be useful for maintaining custom classes and other attributes which have
+ * been explicitly assigned to the row.
+ *
+ * DataTables 1.10+ has `dt-api row.add()` and `dt-api rows.add()` which have
+ * this ability built in, and extend it to be able to use jQuery objects as well
+ * as plain `dt-tag tr` elements. As such this method is marked deprecated, but
+ * is available for use with legacy version of DataTables. Please use the
+ * new API if you are used DataTables 1.10 or newer.
*
* @name fnAddTr
- * @summary
+ * @summary Add a `dt-tag tr` element to the table
* @author [Allan Jardine](http://sprymedia.co.uk)
+ * @deprecated
+ *
+ * @param {node} nTr `dt-tag tr` element to add to the table
+ * @param {boolean} [bRedraw=false] Indicate if the table should do a redraw or not.
*
* @example
- *
+ * var table = $('#example').dataTable();
+ * table.fnAddTr( $('
'+
+ * '1 | '+
+ * '2 | '+
+ * '3 | '+
+ * '
')[0]
+ * );
*/
jQuery.fn.dataTableExt.oApi.fnAddTr = function ( oSettings, nTr, bRedraw ) {
diff --git a/api/fnColumnIndexToVisible.js b/api/fnColumnIndexToVisible.js
index f3aa858..2e106ec 100644
--- a/api/fnColumnIndexToVisible.js
+++ b/api/fnColumnIndexToVisible.js
@@ -1,19 +1,33 @@
/**
- * When DataTables removes columns from the display (bVisible or
- * fnSetColumnVis) it removes these elements from the DOM, effecting the
- * index value for the column positions. This function converts the data
- * column index (i.e. all columns regardless of visibility) into a visible
- * column index.
+ * When DataTables removes columns from the display (`bVisible` or
+ * `fnSetColumnVis`) it removes these elements from the DOM, effecting the index
+ * value for the column positions. This function converts the data column index
+ * (i.e. all columns regardless of visibility) into a visible column index.
+ *
+ * DataTables 1.10+ has this ability built-in through the
+ * `dt-api column.index()` method. As such this method is marked deprecated, but
+ * is available for use with legacy version of DataTables.
*
* @name fnColumnIndexToVisible
- * @summary
+ * @summary Convert a column data index to a visible index.
* @author [Allan Jardine](http://sprymedia.co.uk)
+ * @deprecated
+ *
+ * @param {integer} iMatch Column data index to convert to visible index
+ * @returns {integer} Visible column index
*
* @example
- *
+ * var table = $('#example').dataTable( {
+ * aoColumnDefs: [
+ * { bVisible: false, aTargets: [1] }
+ * ]
+ * } );
+ *
+ * // This will show 1
+ * alert( 'Column 2 visible index: '+table.fnColumnIndexToVisible(2) );
*/
-$.fn.dataTableExt.oApi.fnColumnIndexToVisible = function ( oSettings, iMatch )
+jQuery.fn.dataTableExt.oApi.fnColumnIndexToVisible = function ( oSettings, iMatch )
{
- return oSettings.oApi._fnColumnIndexToVisible( oSettings, iMatch );
+ return oSettings.oApi._fnColumnIndexToVisible( oSettings, iMatch );
};
diff --git a/api/fnDataUpdate.js b/api/fnDataUpdate.js
index eed9b04..371e366 100644
--- a/api/fnDataUpdate.js
+++ b/api/fnDataUpdate.js
@@ -1,13 +1,19 @@
/**
- * Update the internal data for a TR element based on what is used in the
+ * Update the internal data for a `dt-tag tr` element based on what is used in the
* DOM. You will likely want to call fnDraw() after this function.
*
+ * DataTables 1.10+ has this ability built-in through the
+ * `dt-api row().invalidate()` method. As such this method is marked deprecated,
+ * but is available for use with legacy version of DataTables. Please use the
+ * new API if you are used DataTables 1.10 or newer.
+ *
* @name fnDataUpdate
- * @summary
+ * @summary Update DataTables cached data from the DOM
* @author Lior Gerson
+ * @deprecated
*
- * @example
- *
+ * @param {node} nTr `dt-tag tr` element to get the data from
+ * @param {integer} iRowIndex Row's position in the table (`fnGetPosition`).
*/
jQuery.fn.dataTableExt.oApi.fnDataUpdate = function ( oSettings, nRowObject, iRowIndex )
diff --git a/api/fnDisplayRow.js b/api/fnDisplayRow.js
index d7636d0..ce47834 100644
--- a/api/fnDisplayRow.js
+++ b/api/fnDisplayRow.js
@@ -1,16 +1,17 @@
/**
- * Take a TR element and alter the table's paging to show the TR in question.
+ * This plug-in will take a `dt-tag tr` element and alter the table's paging
+ * to make that `dt-tag tr` element (i.e. that row) visible.
*
* @name fnDisplayRow
- * @summary
+ * @summary Shift the table's paging to display a given `dt-tag tr` element
* @author [Allan Jardine](http://sprymedia.co.uk)
*
+ * @param {node} nRow Row to display
+ *
* @example
- * $(document).ready(function() {
- * // Display the 21st row in the table
- * var oTable = $('#example').dataTable();
- * oTable.fnDisplayRow( oTable.fnGetNodes()[20] );
- * } );
+ * // Display the 21st row in the table
+ * var table = $('#example').dataTable();
+ * table.fnDisplayRow( table.fnGetNodes()[20] );
*/
jQuery.fn.dataTableExt.oApi.fnDisplayRow = function ( oSettings, nRow )
@@ -36,7 +37,9 @@ jQuery.fn.dataTableExt.oApi.fnDisplayRow = function ( oSettings, nRow )
if( iPos >= 0 )
{
oSettings._iDisplayStart = ( Math.floor(i / oSettings._iDisplayLength) ) * oSettings._iDisplayLength;
- this.oApi._fnCalculateEnd( oSettings );
+ if ( this.oApi._fnCalculateEnd ) {
+ this.oApi._fnCalculateEnd( oSettings );
+ }
}
this.oApi._fnDraw( oSettings );
diff --git a/api/fnDisplayStart.js b/api/fnDisplayStart.js
index 523499b..4bb273b 100644
--- a/api/fnDisplayStart.js
+++ b/api/fnDisplayStart.js
@@ -3,25 +3,30 @@
* table.
*
* @name fnDisplayStart
- * @summary
+ * @summary Change the table's paging display start.
* @author [Allan Jardine](http://sprymedia.co.uk)
+ * @deprecated
+ *
+ * @param {integer} iStart Display start index.
+ * @param {boolean} [bRedraw=false] Indicate if the table should do a redraw or not.
*
* @example
- *
+ * var table = $('#example').dataTable();
+ * table.fnDisplayStart( 21 );
*/
jQuery.fn.dataTableExt.oApi.fnDisplayStart = function ( oSettings, iStart, bRedraw )
{
- if ( typeof bRedraw == 'undefined' )
- {
+ if ( typeof bRedraw == 'undefined' ) {
bRedraw = true;
}
oSettings._iDisplayStart = iStart;
- oSettings.oApi._fnCalculateEnd( oSettings );
+ if ( oSettings.oApi._fnCalculateEnd ) {
+ oSettings.oApi._fnCalculateEnd( oSettings );
+ }
- if ( bRedraw )
- {
+ if ( bRedraw ) {
oSettings.oApi._fnDraw( oSettings );
}
};
diff --git a/api/fnFakeRowspan.js b/api/fnFakeRowspan.js
index dd8bd89..e3d9f48 100644
--- a/api/fnFakeRowspan.js
+++ b/api/fnFakeRowspan.js
@@ -1,13 +1,19 @@
/**
- * Creates rowspan cells in a column when there are two or more cells in a
+ * Creates `rowspan` cells in a column when there are two or more cells in a
* row with the same content, effectively grouping them together visually.
- * *Note* - this plug-in currently only operates correctly with
- * *server-side processing*.
+ *
+ * **Note** - this plug-in currently only operates correctly with
+ * **server-side processing**.
*
* @name fnFakeRowspan
- * @summary
+ * @summary Create a rowspan for cells which share data
* @author Fredrik Wendel
*
+ * @param {interger} iColumn Column index to have row span
+ * @param {boolean} [bCaseSensitive=true] If the data check should be case
+ * sensitive or not.
+ * @returns {jQuery} jQuery instance
+ *
* @example
* $('#example').dataTable().fnFakeRowspan(3);
*/
diff --git a/api/fnFilterAll.js b/api/fnFilterAll.js
index 194f3be..6a4cf92 100644
--- a/api/fnFilterAll.js
+++ b/api/fnFilterAll.js
@@ -1,19 +1,31 @@
/**
* Apply the same filter to all DataTable instances on a particular page. The
- * function call exactly matches that used by fnFilter() so regular expression
+ * function call exactly matches that used by `fnFilter()` so regular expression
* and individual column sorting can be used.
*
+ * DataTables 1.10+ provides this ability through its new API, which is able to
+ * to control multiple tables at a time.
+ * `$('.dataTable').DataTable().search( ... )` for example will apply the same
+ * filter to all tables on the page. The new API should be used in preference
+ * to this older method if at all possible.
+ *
* @name fnFilterAll
- * @summary
+ * @summary Apply a common filter to all DataTables on a page
* @author [Kristoffer Karlström](http://www.kmmtiming.se/)
+ * @deprecated
+ *
+ * @param {string} sInput Filtering input
+ * @param {integer} [iColumn=null] Column to apply the filter to
+ * @param {boolean} [bRegex] Regular expression flag
+ * @param {boolean} [bSmart] Smart filtering flag
*
* @example
* $(document).ready(function() {
- * var oTable = $(".dataTable").dataTable();
+ * var table = $(".dataTable").dataTable();
*
* $("#search").keyup( function () {
* // Filter on the column (the index) of this element
- * oTable.fnFilterAll(this.value);
+ * table.fnFilterAll(this.value);
* } );
* });
*/
diff --git a/api/fnFilterClear.js b/api/fnFilterClear.js
index fe7b57a..763e2e4 100644
--- a/api/fnFilterClear.js
+++ b/api/fnFilterClear.js
@@ -2,20 +2,34 @@
* Remove all filtering that has been applied to a DataTable, be it column
* based filtering or global filtering.
*
+ * DataTables 1.10+ new API can achieve the same effect as this plug-in, without
+ * the requirement for plug-ins using the following chaining:
+ *
+ * ```js
+ * var table = $('#example').DataTable();
+ * table
+ * .search( '' )
+ * .columns().search( '' )
+ * .draw();
+ * ```
+ *
+ * Please use the new API in DataTables 1.10+ is you are able to do so.
+ *
* @name fnFilterClear
- * @summary
+ * @summary Remove all column and global filters applied to a table
* @author [Allan Jardine](http://sprymedia.co.uk)
+ * @deprecated
*
* @example
* $(document).ready(function() {
- * var oTable = $('#example').dataTable();
+ * var table = $('#example').dataTable();
*
* // Perform a filter
- * oTable.fnFilter('Win');
- * oTable.fnFilter('Trident', 0);
+ * table.fnFilter('Win');
+ * table.fnFilter('Trident', 0);
*
* // Remove all filtering
- * oTable.fnFilterClear();
+ * table.fnFilterClear();
* } );
*/
diff --git a/api/fnFilterOnReturn.js b/api/fnFilterOnReturn.js
index 3e2dad6..8737bc4 100644
--- a/api/fnFilterOnReturn.js
+++ b/api/fnFilterOnReturn.js
@@ -1,12 +1,14 @@
/**
- * This plug-in removed the default behaviour of DataTables to filter on each
+ * This plug-in removes the default behaviour of DataTables to filter on each
* keypress, and replaces with it the requirement to press the enter key to
* perform the filter.
*
* @name fnFilterOnReturn
- * @summary
+ * @summary Require the return key to be pressed to filter a table
* @author [Jon Ranes](http://www.mvccms.com/)
*
+ * @returns {jQuery} jQuery instance
+ *
* @example
* $(document).ready(function() {
* $('.dataTable').dataTable().fnFilterOnReturn();
@@ -20,12 +22,14 @@ jQuery.fn.dataTableExt.oApi.fnFilterOnReturn = function (oSettings) {
$.fn.dataTableExt.iApiIndex = i;
var $this = this;
var anControl = $('input', _that.fnSettings().aanFeatures.f);
- anControl.unbind('keyup').bind('keypress', function (e) {
- if (e.which == 13) {
- $.fn.dataTableExt.iApiIndex = i;
- _that.fnFilter(anControl.val());
- }
- });
+ anControl
+ .unbind('keyup search input')
+ .bind('keypress', function (e) {
+ if (e.which == 13) {
+ $.fn.dataTableExt.iApiIndex = i;
+ _that.fnFilter(anControl.val());
+ }
+ });
return this;
});
return this;
diff --git a/api/fnFindCellRowIndexes.js b/api/fnFindCellRowIndexes.js
index f78a738..fdebd54 100644
--- a/api/fnFindCellRowIndexes.js
+++ b/api/fnFindCellRowIndexes.js
@@ -5,16 +5,20 @@
* match.
*
* @name fnFindCellRowIndexes
- * @summary
+ * @summary Search for data, returning row indexes
* @author [Allan Jardine](http://sprymedia.co.uk)
*
+ * @param {string} sSearch Data to search for
+ * @param {integer} [iColumn=null] Limit search to this column
+ * @returns {array} Array of row indexes with this data
+ *
* @example
* $(document).ready(function() {
- * var oTable = $('#example').dataTable();
+ * var table = $('#example').dataTable();
*
- * var a = oTable.fnFindCellRowIndexes( '1.7' ); // Search all columns
+ * var a = table.fnFindCellRowIndexes( '1.7' ); // Search all columns
*
- * var b = oTable.fnFindCellRowIndexes( '1.7', 3 ); // Search only column 3
+ * var b = table.fnFindCellRowIndexes( '1.7', 3 ); // Search only column 3
* } );
*/
@@ -28,7 +32,7 @@ jQuery.fn.dataTableExt.oApi.fnFindCellRowIndexes = function ( oSettings, sSearch
{
aData = oSettings.aoData[i]._aData;
- if ( typeof iColumn == 'undefined' )
+ if ( iColumn === undefined )
{
for ( j=0, jLen=aData.length ; j= 0 ) {
var page = Math.floor( pos / this.page.info().length );
this.page( page ).draw( false );
}
+
+ return this;
} );
\ No newline at end of file
diff --git a/api/sum().js b/api/sum().js
index 212ccbd..a024a34 100644
--- a/api/sum().js
+++ b/api/sum().js
@@ -1,13 +1,31 @@
/**
- * Sum the values in a data set.
+ * Fairly simply, this plug-in will take the data from an API result set
+ * and sum it, returning the summed value. The data can come from any data
+ * source, including column data, cells or rows.
*
* @name sum()
- * @summary
+ * @summary Sum the values in a data set.
* @author [Allan Jardine](http://sprymedia.co.uk)
* @requires DataTables 1.10+
*
+ * @returns {Number} Summed value
+ *
* @example
+ * // Simply get the sum of a column
+ * var table = $('#example').DataTable();
* table.column( 3 ).data().sum();
+ *
+ * @example
+ * // Insert the sum of a column into the columns footer, for the visible
+ * // data on each draw
+ * $('#example').DataTable( {
+ * drawCallback: function () {
+ * var api = this.api();
+ * api.table().footer().to$().html(
+ * api.column( 4, {page:'current'} ).data().sum()
+ * );
+ * }
+ * } );
*/
jQuery.fn.dataTable.Api.register( 'sum()', function () {