Removed: Legacy API methods are no longer available in DataTables 2

This commit removes the plug-ins that were DataTables 1 specific
at
Allan Jardine 10 months ago
parent 484094059e
commit b5ca536b63

@ -1,63 +0,0 @@
/**
* 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 `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`).
*
* @name fnAddDataAndDisplay
* @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 table = $('#example').dataTable();
* table.fnAddDataAndDisplay( [ 1, 2, 3, 4, 5, ... ] );
* } );
*/
jQuery.fn.dataTableExt.oApi.fnAddDataAndDisplay = function ( oSettings, aData )
{
/* Add the data */
var iAdded = this.oApi._fnAddData( oSettings, aData );
var nAdded = oSettings.aoData[ iAdded ].nTr;
/* Need to re-filter and re-sort the table to get positioning correct, not perfect
* as this will actually redraw the table on screen, but the update should be so fast (and
* possibly not alter what is already on display) that the user will not notice
*/
this.oApi._fnReDraw( oSettings );
/* Find it's position in the table */
var iPos = -1;
for( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ )
{
if( oSettings.aoData[ oSettings.aiDisplay[i] ].nTr == nAdded )
{
iPos = i;
break;
}
}
/* Get starting point, taking account of paging */
if( iPos >= 0 )
{
oSettings._iDisplayStart = ( Math.floor(i / oSettings._iDisplayLength) ) * oSettings._iDisplayLength;
if ( this.oApi._fnCalculateEnd ) {
this.oApi._fnCalculateEnd( oSettings );
}
}
this.oApi._fnDraw( oSettings );
return {
"nTr": nAdded,
"iPos": iAdded
};
};

@ -1,74 +0,0 @@
/**
* 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 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( $('<tr>'+
* '<td>1</td>'+
* '<td>2</td>'+
* '<td>3</td>'+
* '</tr>')[0]
* );
*/
jQuery.fn.dataTableExt.oApi.fnAddTr = function ( oSettings, nTr, bRedraw ) {
if ( typeof bRedraw == 'undefined' )
{
bRedraw = true;
}
var nTds = nTr.getElementsByTagName('td');
if ( nTds.length != oSettings.aoColumns.length )
{
alert( 'Warning: not adding new TR - columns and TD elements must match' );
return;
}
var aData = [];
var aInvisible = [];
var i;
for ( i=0 ; i<nTds.length ; i++ )
{
aData.push( nTds[i].innerHTML );
if (!oSettings.aoColumns[i].bVisible)
{
aInvisible.push( i );
}
}
/* Add the data and then replace DataTable's generated TR with ours */
var iIndex = this.oApi._fnAddData( oSettings, aData );
nTr._DT_RowIndex = iIndex;
oSettings.aoData[ iIndex ].nTr = nTr;
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
// Hidding invisible columns
for ( i = (aInvisible.length - 1) ; i >= 0 ; i-- )
{
oSettings.aoData[iIndex]._anHidden[ i ] = nTds[aInvisible[i]];
nTr.removeChild( nTds[aInvisible[i]] );
}
// Redraw
if ( bRedraw )
{
this.oApi._fnReDraw( oSettings );
}
};

@ -1,33 +0,0 @@
/**
* 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 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) );
*/
jQuery.fn.dataTableExt.oApi.fnColumnIndexToVisible = function ( oSettings, iMatch )
{
return oSettings.oApi._fnColumnIndexToVisible( oSettings, iMatch );
};

@ -1,25 +0,0 @@
/**
* 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 Update DataTables cached data from the DOM
* @author Lior Gerson
* @deprecated
*
* @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 )
{
jQuery(nRowObject).find("TD").each( function(i) {
var iColIndex = oSettings.oApi._fnVisibleToColumnIndex( oSettings, i );
oSettings.oApi._fnSetCellData( oSettings, iRowIndex, iColIndex, jQuery(this).html() );
} );
};

@ -1,46 +0,0 @@
/**
* 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 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
* // Display the 21st row in the table
* var table = $('#example').dataTable();
* table.fnDisplayRow( table.fnGetNodes()[20] );
*/
jQuery.fn.dataTableExt.oApi.fnDisplayRow = function ( oSettings, nRow )
{
// Account for the "display" all case - row is already displayed
if ( oSettings._iDisplayLength == -1 )
{
return;
}
// Find the node in the table
var iPos = -1;
for( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ )
{
if( oSettings.aoData[ oSettings.aiDisplay[i] ].nTr == nRow )
{
iPos = i;
break;
}
}
// Alter the start point of the paging display
if( iPos >= 0 )
{
oSettings._iDisplayStart = ( Math.floor(i / oSettings._iDisplayLength) ) * oSettings._iDisplayLength;
if ( this.oApi._fnCalculateEnd ) {
this.oApi._fnCalculateEnd( oSettings );
}
}
this.oApi._fnDraw( oSettings );
};

@ -1,32 +0,0 @@
/**
* Set the point at which DataTables will start it's display of data in the
* table.
*
* @name fnDisplayStart
* @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' ) {
bRedraw = true;
}
oSettings._iDisplayStart = iStart;
if ( oSettings.oApi._fnCalculateEnd ) {
oSettings.oApi._fnCalculateEnd( oSettings );
}
if ( bRedraw ) {
oSettings.oApi._fnDraw( oSettings );
}
};

@ -1,66 +0,0 @@
/**
* 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**.
*
* @name fnFakeRowspan
* @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);
*/
jQuery.fn.dataTableExt.oApi.fnFakeRowspan = function ( oSettings, iColumn, bCaseSensitive ) {
/* Fail silently on missing/errorenous parameter data. */
if (isNaN(iColumn)) {
return false;
}
if (iColumn < 0 || iColumn > oSettings.aoColumns.length-1) {
alert ('Invalid column number choosen, must be between 0 and ' + (oSettings.aoColumns.length-1));
return false;
}
bCaseSensitive = (typeof(bCaseSensitive) != 'boolean' ? true : bCaseSensitive);
function fakeRowspan () {
var firstOccurance = null,
value = null,
rowspan = 0;
jQuery.each(oSettings.aoData, function (i, oData) {
var val = oData._aData[iColumn],
cell = oData.nTr.childNodes[iColumn];
/* Use lowercase comparison if not case-sensitive. */
if (!bCaseSensitive) {
val = val.toLowerCase();
}
/* Reset values on new cell data. */
if (val != value) {
value = val;
firstOccurance = cell;
rowspan = 0;
}
if (val == value) {
rowspan++;
}
if (firstOccurance !== null && val == value && rowspan > 1) {
oData.nTr.removeChild(cell);
firstOccurance.rowSpan = rowspan;
}
});
}
oSettings.aoDrawCallback.push({ "fn": fakeRowspan, "sName": "fnFakeRowspan" });
return this;
};

@ -1,39 +0,0 @@
/**
* Apply the same filter to all DataTable instances on a particular page. The
* 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 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 table = $(".dataTable").dataTable();
*
* $("#search").keyup( function () {
* // Filter on the column (the index) of this element
* table.fnFilterAll(this.value);
* } );
* });
*/
jQuery.fn.dataTableExt.oApi.fnFilterAll = function(oSettings, sInput, iColumn, bRegex, bSmart) {
var settings = $.fn.dataTableSettings;
for ( var i=0 ; i<settings.length ; i++ ) {
settings[i].oInstance.fnFilter( sInput, iColumn, bRegex, bSmart);
}
};

@ -1,63 +0,0 @@
/**
* 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 Remove all column and global filters applied to a table
* @author [Allan Jardine](http://sprymedia.co.uk)
* @deprecated
*
* @example
* $(document).ready(function() {
* var table = $('#example').dataTable();
*
* // Perform a filter
* table.fnFilter('Win');
* table.fnFilter('Trident', 0);
*
* // Remove all filtering
* table.fnFilterClear();
* } );
*/
jQuery.fn.dataTableExt.oApi.fnFilterClear = function ( oSettings )
{
var i, iLen;
/* Remove global filter */
oSettings.oPreviousSearch.sSearch = "";
/* Remove the text of the global filter in the input boxes */
if ( typeof oSettings.aanFeatures.f != 'undefined' )
{
var n = oSettings.aanFeatures.f;
for ( i=0, iLen=n.length ; i<iLen ; i++ )
{
$('input', n[i]).val( '' );
}
}
/* Remove the search text for the column filters - NOTE - if you have input boxes for these
* filters, these will need to be reset
*/
for ( i=0, iLen=oSettings.aoPreSearchCols.length ; i<iLen ; i++ )
{
oSettings.aoPreSearchCols[i].sSearch = "";
}
/* Redraw */
oSettings.oApi._fnReDraw( oSettings );
};

@ -1,36 +0,0 @@
/**
* 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 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();
* } );
*/
jQuery.fn.dataTableExt.oApi.fnFilterOnReturn = function (oSettings) {
var _that = this;
this.each(function (i) {
$.fn.dataTableExt.iApiIndex = i;
var $this = this;
var anControl = $('input', _that.fnSettings().aanFeatures.f);
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;
};

@ -1,55 +0,0 @@
/**
* Search through a table looking for a given string (optionally the search
* can be restricted to a single column). The return value is an array with
* the data indexes (from DataTables' internal data store) for any rows which
* match.
*
* @name fnFindCellRowIndexes
* @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 table = $('#example').dataTable();
*
* var a = table.fnFindCellRowIndexes( '1.7' ); // Search all columns
*
* var b = table.fnFindCellRowIndexes( '1.7', 3 ); // Search only column 3
* } );
*/
jQuery.fn.dataTableExt.oApi.fnFindCellRowIndexes = function ( oSettings, sSearch, iColumn )
{
var
i,iLen, j, jLen, val,
aOut = [], aData,
columns = oSettings.aoColumns;
for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
{
aData = oSettings.aoData[i]._aData;
if ( iColumn === undefined )
{
for ( j=0, jLen=columns.length ; j<jLen ; j++ )
{
val = this.fnGetData(i, j);
if ( val == sSearch )
{
aOut.push( i );
}
}
}
else if (this.fnGetData(i, iColumn) == sSearch )
{
aOut.push( i );
}
}
return aOut;
};

@ -1,55 +0,0 @@
/**
* Much like `fnFindCellRowIndexes` this plug-in will search a table for
* matching data (optionally the search can be restricted to a single column),
* but in this case the returned array contains `dt-tag tr` nodes of the
* matching rows, rather than data indexes.
*
* @name fnFindCellRowNodes
* @summary Search for data, returning row nodes
* @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 `dt-tag tr` element with this data
*
* @example
* $(document).ready(function() {
* var table = $('#example').dataTable();
*
* var a = table.fnFindCellRowNodes( '1.7' ); // Search all columns
*
* var b = table.fnFindCellRowNodes( '1.7', 3 ); // Search only column 3
* } );
*/
jQuery.fn.dataTableExt.oApi.fnFindCellRowNodes = function ( oSettings, sSearch, iColumn )
{
var
i,iLen, j, jLen, val,
aOut = [], aData,
columns = oSettings.aoColumns;
for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
{
aData = oSettings.aoData[i]._aData;
if ( iColumn === undefined )
{
for ( j=0, jLen=columns.length ; j<jLen ; j++ )
{
val = this.fnGetData(i, j);
if ( val == sSearch )
{
aOut.push( oSettings.aoData[i].nTr );
}
}
}
else if (this.fnGetData(i, iColumn) == sSearch )
{
aOut.push( oSettings.aoData[i].nTr );
}
}
return aOut;
};

@ -1,55 +0,0 @@
/**
* Due to the fact that DataTables moves DOM elements around (mainly `dt-tag tr`
* elements for sorting and filtering) it can at times be a little tricky to get
* the next row based on another, while taking into account pagination,
* filtering, sorting etc.
*
* This function is designed to address exactly this situation. It takes two
* parameters, the target node, and a boolean indicating if the adjacent row
* retrieved should be the next (`true`, or no value) or the previous (`false`).
*
* @name fnGetAdjacentTr
* @summary Get the adjacent `dt-tag tr` element for a row.
* @author [Allan Jardine](http://sprymedia.co.uk)
*
* @param {node} nTr `dt-tag tr` element to get the adjacent element of
* @param {boolean} [bNext=true] Get the next (`true`), or previous (`false`)
* `dt-tag tr` element.
* @returns {node} `dt-tag tr` element or null if not found.
*
* @example
* $(document).ready(function() {
* var table = $('#example').dataTable();
*
* var n1 = $('#example tbody tr').eq(2)[0];
* var next = table.fnGetAdjacentTr( n1 );
* var prev = table.fnGetAdjacentTr( n1, false );
* } );
*/
jQuery.fn.dataTableExt.oApi.fnGetAdjacentTr = function ( oSettings, nTr, bNext )
{
/* Find the node's position in the aoData store */
var iCurrent = oSettings.oApi._fnNodeToDataIndex( oSettings, nTr );
/* Convert that to a position in the display array */
var iDisplayIndex = $.inArray( iCurrent, oSettings.aiDisplay );
if ( iDisplayIndex == -1 )
{
/* Not in the current display */
return null;
}
/* Move along the display array as needed */
iDisplayIndex += (typeof bNext=='undefined' || bNext) ? 1 : -1;
/* Check that it within bounds */
if ( iDisplayIndex < 0 || iDisplayIndex >= oSettings.aiDisplay.length )
{
/* There is no next/previous element */
return null;
}
/* Return the target node from the aoData store */
return oSettings.aoData[ oSettings.aiDisplay[ iDisplayIndex ] ].nTr;
};

@ -1,83 +0,0 @@
/**
* Return an array of table values from a particular column, with various
* filtering options.
*
* DataTables 1.10+ provides the `dt-api column().data()` method, built-in to
* the core, to provide this ability. 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 fnGetColumnData
* @summary Get the data from a column
* @author [Benedikt Forchhammer](http://mind2.de)
* @deprecated
*
* @param {integer} iColumn Column to get data from
* @param {boolean} [bFiltered=true] Reduce the data set to only unique values
* @param {boolean} [bUnique=true] Get data from filter results only
* @param {boolean} [bIgnoreEmpty=true] Remove data elements which are empty
* @returns {array} Array of data from the column
*
* @example
* var table = $('#example').dataTable();
* table.fnGetColumnData( 3 );
*/
jQuery.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
// check that we have a column id
if ( typeof iColumn == "undefined" ) {
return [];
}
// by default we only wany unique data
if ( typeof bUnique == "undefined" ) {
bUnique = true;
}
// by default we do want to only look at filtered data
if ( typeof bFiltered == "undefined" ) {
bFiltered = true;
}
// by default we do not wany to include empty values
if ( typeof bIgnoreEmpty == "undefined" ) {
bIgnoreEmpty = true;
}
// list of rows which we're going to loop through
var aiRows;
// use only filtered rows
if (bFiltered === true) {
aiRows = oSettings.aiDisplay;
}
// use all rows
else {
aiRows = oSettings.aiDisplayMaster; // all row numbers
}
// set up data array
var asResultData = [];
for (var i=0,c=aiRows.length; i<c; i++) {
var iRow = aiRows[i];
var sValue = this.fnGetData(iRow, iColumn);
// ignore empty values?
if (bIgnoreEmpty === true && sValue.length === 0) {
continue;
}
// ignore unique values?
else if (bUnique === true && jQuery.inArray(sValue, asResultData) > -1) {
continue;
}
// else push the value onto the result data array
else {
asResultData.push(sValue);
}
}
return asResultData;
};

@ -1,31 +0,0 @@
/**
* Maintenance of web-sites can often cause unexpected headaches, particularly
* if the hardcoded index of an array (the columns in a DataTables instance)
* needs to change due to an added or removed column. This plug-in function
* will match a given string to the title of a column in the table and return
* the column index, helping to overcome this problem.
*
* @name fnGetColumnIndex
* @summary Get the column index by searching the column titles
* @author [Michael Ross](http://www.rosstechassociates.com/)
*
* @param {string} sCol Column title to search for
* @returns {integer} Column index, or -1 if not found
*
* @example
* var table = $('#example').dataTable();
* table.fnGetColumnIndex( 'Browser' );
*/
jQuery.fn.dataTableExt.oApi.fnGetColumnIndex = function ( oSettings, sCol )
{
var cols = oSettings.aoColumns;
for ( var x=0, xLen=cols.length ; x<xLen ; x++ )
{
if ( cols[x].sTitle.toLowerCase() == sCol.toLowerCase() )
{
return x;
}
}
return -1;
};

@ -1,43 +0,0 @@
/**
* Get a list of all `dt-tag tr` nodes in the table which are not currently
* visible (useful for building forms).
*
* This function is marked as deprecated as using the `dt-api rows()` method in
* DataTables 1.10+ is preferred to this approach.
*
* @name fnGetHiddenNodes
* @summary Get the `dt-tag tr` elements which are not in the DOM
* @author [Allan Jardine](http://sprymedia.co.uk)
* @deprecated
*
* @example
* var table = $('#example').dataTable();
* var nodes = table.fnGetHiddenNodes();
*/
jQuery.fn.dataTableExt.oApi.fnGetHiddenNodes = function ( settings )
{
var nodes;
var display = jQuery('tbody tr', settings.nTable);
if ( jQuery.fn.dataTable.versionCheck ) {
// DataTables 1.10
var api = new jQuery.fn.dataTable.Api( settings );
nodes = api.rows().nodes().toArray();
}
else {
// 1.9-
nodes = this.oApi._fnGetTrNodes( settings );
}
/* Remove nodes which are being displayed */
for ( var i=0 ; i<display.length ; i++ ) {
var iIndex = jQuery.inArray( display[i], nodes );
if ( iIndex != -1 ) {
nodes.splice( iIndex, 1 );
}
}
return nodes;
};

@ -1,59 +0,0 @@
/**
* Get a `dt-tag td` node from a row, taking into account column visibility.
* While getting a `dt-tag td` node is easy when it is visible on the page by
* using normal DOM methods, jQuery or whatever, it becomes a lot more
* complicated when taking into account hidden rows and columns. This function
* can be used to overcome these difficulties.
*
* DataTables 1.10+'s new API provides the `dt-api cell()` and `dt-api cells()`
* methods which are preferable for use over this 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 fnGetTd
* @summary Get the `dt-tag td` element for a cell.
* @author [Allan Jardine](http://sprymedia.co.uk)
* @deprecated
*
* @param {node} mTr `dt-tag tr` element to get the `dt-tag td` of
* @param {integer} iTd Column index to get the node of
* @param {boolean} bVisOnly Consider visible columns only
* @returns {node} `dt-tag td` element in question
*
* @example
* $(document).ready(function() {
* var table = $('#example').dataTable();
*
* // Sort in the order that was origially in the HTML
* var nTd = table.fnGetTd( $('#example tbody tr:eq(1)')[0], 1 );
* console.log( nTd );
* } );
*/
jQuery.fn.dataTableExt.oApi.fnGetTd = function ( oSettings, mTr, iTd, bVisOnly )
{
/* Take either a TR node or aoData index as the mTr property */
var iRow = (typeof mTr == 'object') ?
oSettings.oApi._fnNodeToDataIndex(oSettings, mTr) : mTr;
if ( typeof bVisOnly == 'undefined' && !bVisOnly )
{
/* Looking at both visible and hidden TD elements - convert to visible index, if not present
* then it must be hidden. Return as appropriate
*/
var iCalcVis = oSettings.oApi._fnColumnIndexToVisible( oSettings, iTd );
if ( iCalcVis !== null )
{
return oSettings.aoData[ iRow ].nTr.getElementsByTagName('td')[ iCalcVis ];
}
else
{
return oSettings.aoData[ iRow ]._anHidden[ iTd ];
}
}
else
{
/* Only looking at visible TD elements, so just use getElements... */
return oSettings.aoData[ iRow ].nTr.getElementsByTagName('td')[ iTd ];
}
};

@ -1,65 +0,0 @@
/**
* Get an array of `dt-tag td` nodes from DataTables for a given row, including
* any column elements which are hidden.
*
* DataTables 1.10 has the `dt-api cells().nodes()` method, built-in, to provide
* this functionality. 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 fnGetTds
* @summary Get the `dt-tag td` elements for a row
* @author [Allan Jardine](http://sprymedia.co.uk)
* @deprecated
*
* @param {node} mTr `dt-tag tr` element to get the `dt-tag td` of
* @returns {array} Array of `dt-tag td` elements
*
* @example
* $(document).ready(function() {
* var oTable = $('#example').dataTable();
*
* // Sort in the order that was origially in the HTML
* var anTds = oTable.fnGetTds( $('#example tbody tr:eq(1)')[0] );
* console.log( anTds );
* } );
*/
jQuery.fn.dataTableExt.oApi.fnGetTds = function ( oSettings, mTr )
{
var anTds = [];
var anVisibleTds = [];
var iCorrector = 0;
var nTd, iColumn, iColumns;
/* Take either a TR node or aoData index as the mTr property */
var iRow = (typeof mTr == 'object') ?
oSettings.oApi._fnNodeToDataIndex(oSettings, mTr) : mTr;
var nTr = oSettings.aoData[iRow].nTr;
/* Get an array of the visible TD elements */
for ( iColumn=0, iColumns=nTr.childNodes.length ; iColumn<iColumns ; iColumn++ )
{
nTd = nTr.childNodes[iColumn];
if ( nTd.nodeName.toUpperCase() == "TD" )
{
anVisibleTds.push( nTd );
}
}
/* Construct and array of the combined elements */
for ( iColumn=0, iColumns=oSettings.aoColumns.length ; iColumn<iColumns ; iColumn++ )
{
if ( oSettings.aoColumns[iColumn].bVisible )
{
anTds.push( anVisibleTds[iColumn-iCorrector] );
}
else
{
anTds.push( oSettings.aoData[iRow]._anHidden[iColumn] );
iCorrector++;
}
}
return anTds;
};

@ -1,48 +0,0 @@
/**
* Change the number of records that can be viewed on a single page in
* DataTables.
*
* DataTables 1.10 provides the `dt-api page.len()` method to get and set the
* page length using the built-in API. 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 fnLengthChange
* @summary Change the paging display length
* @author [Pedro Alves](http://www.webdetails.pt/)
* @deprecated
*
* @example
* $(document).ready(function() {
* var table = $('#example').dataTable();
* table.fnLengthChange( 100 );
* } );
*/
jQuery.fn.dataTableExt.oApi.fnLengthChange = function ( oSettings, iDisplay )
{
oSettings._iDisplayLength = iDisplay;
oSettings.oApi._fnCalculateEnd( oSettings );
/* If we have space to show extra rows (backing up from the end point - then do so */
if ( oSettings._iDisplayEnd == oSettings.aiDisplay.length )
{
oSettings._iDisplayStart = oSettings._iDisplayEnd - oSettings._iDisplayLength;
if ( oSettings._iDisplayStart < 0 )
{
oSettings._iDisplayStart = 0;
}
}
if ( oSettings._iDisplayLength == -1 )
{
oSettings._iDisplayStart = 0;
}
oSettings.oApi._fnDraw( oSettings );
if ( oSettings.aanFeatures.l )
{
$('select', oSettings.aanFeatures.l).val( iDisplay );
}
};

@ -1,63 +0,0 @@
/**
* This plug-in adds to DataTables the ability to set multiple column filtering
* terms in a single call (particularly useful if using server-side processing).
* Used in combination with the column sName parameter, simply pass in an object
* with the key/value pair being the column you wish to search on, and the value
* you wish to search for.
*
* DataTables 1.10's API provides a easy built-in way to apply multiple filters
* to the table without redrawing until required. For example, the example below
* with the DataTables 1.10 API could be written as:
*
* ```js
* var table = $('#example').DataTable();
* table
* .column( 0 ).search( 'Gecko' )
* .column( 1 ).search( 'Cam' )
* .draw();
* ```
*
* 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 fnMultiFilter
* @summary Apply multiple column filters together
* @author _mrkevans_
* @deprecated
*
* @param {object} oData Data to search for
*
* @example
* $(document).ready(function() {
* var table = $('#example').dataTable( {
* "aoColumns": [
* { "sName": "engine" },
* { "sName": "browser" },
* { "sName": "platform" },
* { "sName": "version" },
* { "sName": "grade" }
* ]
* } );
* table.fnMultiFilter( { "engine": "Gecko", "browser": "Cam" } );
* } );
*/
jQuery.fn.dataTableExt.oApi.fnMultiFilter = function( oSettings, oData ) {
for ( var key in oData )
{
if ( oData.hasOwnProperty(key) )
{
for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
{
if( oSettings.aoColumns[i].sName == key )
{
/* Add single column filter */
oSettings.aoPreSearchCols[ i ].sSearch = oData[key];
break;
}
}
}
}
this.oApi._fnReDraw( oSettings );
};

@ -1,39 +0,0 @@
/**
* Get information about the paging settings that DataTables is currently
* using to display each page, including the number of records shown, start
* and end points in the data set etc.
*
* DataTables 1.10+ provides the `dt-api page.info()` method, built-in, provide
* the same information as this 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 fnPagingInfo
* @summary Get information about the paging state of the table
* @author [Allan Jardine](http://sprymedia.co.uk)
* @deprecated
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "fnDrawCallback": function () {
* alert( 'Now on page'+ this.fnPagingInfo().iPage );
* }
* } );
* } );
*/
jQuery.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
{
return {
"iStart": oSettings._iDisplayStart,
"iEnd": oSettings.fnDisplayEnd(),
"iLength": oSettings._iDisplayLength,
"iTotal": oSettings.fnRecordsTotal(),
"iFilteredTotal": oSettings.fnRecordsDisplay(),
"iPage": oSettings._iDisplayLength === -1 ?
0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
"iTotalPages": oSettings._iDisplayLength === -1 ?
0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
};
};

@ -1,26 +0,0 @@
/**
* When doing some heavy processing of your own (for example using fnOpen with
* data loading from the server) it can be useful to make use of the
* 'processing' indicator built-into DataTables. This plug-in function exposes
* the internal DataTables function so it can be used for exactly this.
*
* @name fnProcessingIndicator
* @summary Show and hide the DataTables processing element through the API.
* @author Allan Chappell
*
* @param {boolean} [onoff=true] Show (`true`) or hide (`false`) the processing
* element.
*
* @example
* var table = $('#example').dataTable();
* table.fnProcessingIndicator(); // On
* table.fnProcessingIndicator(false); // Off
*/
jQuery.fn.dataTableExt.oApi.fnProcessingIndicator = function ( oSettings, onoff )
{
if ( onoff === undefined ) {
onoff = true;
}
this.oApi._fnProcessingDisplay( oSettings, onoff );
};

@ -1,102 +0,0 @@
/**
* By default DataTables only uses the sAjaxSource variable at initialisation
* time, however it can be useful to re-read an Ajax source and have the table
* update. Typically you would need to use the `fnClearTable()` and
* `fnAddData()` functions, however this wraps it all up in a single function
* call.
*
* DataTables 1.10 provides the `dt-api ajax.url()` and `dt-api ajax.reload()`
* methods, built-in, to give the same functionality as this plug-in. 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 fnReloadAjax
* @summary Reload the table's data from the Ajax source
* @author [Allan Jardine](http://sprymedia.co.uk)
* @deprecated
*
* @param {string} [sNewSource] URL to get the data from. If not give, the
* previously used URL is used.
* @param {function} [fnCallback] Callback that is executed when the table has
* redrawn with the new data
* @param {boolean} [bStandingRedraw=false] Standing redraw (don't changing the
* paging)
*
* @example
* var table = $('#example').dataTable();
*
* // Example call to load a new file
* table.fnReloadAjax( 'media/examples_support/json_source2.txt' );
*
* // Example call to reload from original file
* table.fnReloadAjax();
*/
jQuery.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
{
// DataTables 1.10 compatibility - if 1.10 then `versionCheck` exists.
// 1.10's API has ajax reloading built in, so we use those abilities
// directly.
if ( jQuery.fn.dataTable.versionCheck ) {
var api = new jQuery.fn.dataTable.Api( oSettings );
if ( sNewSource ) {
api.ajax.url( sNewSource ).load( fnCallback, !bStandingRedraw );
}
else {
api.ajax.reload( fnCallback, !bStandingRedraw );
}
return;
}
if ( sNewSource !== undefined && sNewSource !== null ) {
oSettings.sAjaxSource = sNewSource;
}
// Server-side processing should just call fnDraw
if ( oSettings.oFeatures.bServerSide ) {
this.fnDraw();
return;
}
this.oApi._fnProcessingDisplay( oSettings, true );
var that = this;
var iStart = oSettings._iDisplayStart;
var aData = [];
this.oApi._fnServerParams( oSettings, aData );
oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aData, function(json) {
/* Clear the old information from the table */
that.oApi._fnClearTable( oSettings );
/* Got the data - add it to the table */
var aData = (oSettings.sAjaxDataProp !== "") ?
that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json;
for ( var i=0 ; i<aData.length ; i++ )
{
that.oApi._fnAddData( oSettings, aData[i] );
}
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
that.fnDraw();
if ( bStandingRedraw === true )
{
oSettings._iDisplayStart = iStart;
that.oApi._fnCalculateEnd( oSettings );
that.fnDraw( false );
}
that.oApi._fnProcessingDisplay( oSettings, false );
/* Callback user function - for event handlers etc */
if ( typeof fnCallback == 'function' && fnCallback !== null )
{
fnCallback( oSettings );
}
}, oSettings );
};

@ -1,56 +0,0 @@
/**
* Enables filtration delay for keeping the browser more responsive while
* searching for a longer keyword.
*
* This can be particularly useful when working with server-side processing,
* where you wouldn't typically want an Ajax request to be made with every key
* press the user makes when searching the table.
*
* Please note that this plug-in has been deprecated and the `dt-init
* searchDelay` option in DataTables 1.10 should now be used. This plug-in will
* not operate with v1.10+.
*
* @name fnSetFilteringDelay
* @summary Add a key debouce delay to the global filtering input of a table
* @author [Zygimantas Berziunas](http://www.zygimantas.com/),
* [Allan Jardine](http://www.sprymedia.co.uk/) and _vex_
*
* @example
* $(document).ready(function() {
* $('.dataTable').dataTable().fnSetFilteringDelay();
* } );
*/
jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) {
var _that = this;
if ( iDelay === undefined ) {
iDelay = 250;
}
this.each( function ( i ) {
if ( typeof _that.fnSettings().aanFeatures.f !== 'undefined' )
{
$.fn.dataTableExt.iApiIndex = i;
var
oTimerId = null,
sPreviousSearch = null,
anControl = $( 'input', _that.fnSettings().aanFeatures.f );
anControl.unbind( 'keyup search input' ).bind( 'keyup search input', function() {
if (sPreviousSearch === null || sPreviousSearch != anControl.val()) {
window.clearTimeout(oTimerId);
sPreviousSearch = anControl.val();
oTimerId = window.setTimeout(function() {
$.fn.dataTableExt.iApiIndex = i;
_that.fnFilter( anControl.val() );
}, iDelay);
}
});
return this;
}
} );
return this;
};

@ -1,36 +0,0 @@
/**
* This function will restore the order in which data was read into a DataTable
* (for example from an HTML source). Although you can set aaSorting to be an
* empty array (`[ ]`) in order to prevent sorting during initialisation, it can
* sometimes be useful to restore the original order after sorting has already
* occurred - which is exactly what this function does.
*
* @name fnSortNeutral
* @summary Change ordering of the table to its data load order
* @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $(document).ready(function() {
* var table = $('#example').dataTable();
*
* // Sort in the order that was originally in the HTML
* table.fnSortNeutral();
* } );
*/
jQuery.fn.dataTableExt.oApi.fnSortNeutral = function ( oSettings )
{
/* Remove any current sorting */
oSettings.aaSorting = [];
/* Sort display arrays so we get them in numerical order */
oSettings.aiDisplay.sort( function (x,y) {
return x-y;
} );
oSettings.aiDisplayMaster.sort( function (x,y) {
return x-y;
} );
/* Redraw */
oSettings.oApi._fnReDraw( oSettings );
};

@ -1,35 +0,0 @@
/**
* Redraw the table (i.e. `fnDraw`) to take account of sorting and filtering,
* but retain the current pagination settings.
*
* DataTables 1.10+ provide the `dt-api draw()` method which has this ability
* built-in (pass the first parameter to the function as `false`). 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 fnStandingRedraw
* @summary Redraw the table without altering the paging
* @author Jonathan Hoguet
* @deprecated
*
* @example
* $(document).ready(function() {
* var table = $('.dataTable').dataTable()
* table.fnStandingRedraw();
* } );
*/
jQuery.fn.dataTableExt.oApi.fnStandingRedraw = function(oSettings) {
if(oSettings.oFeatures.bServerSide === false){
var before = oSettings._iDisplayStart;
oSettings.oApi._fnReDraw(oSettings);
// iDisplayStart has been reset to zero - so lets change it back
oSettings._iDisplayStart = before;
oSettings.oApi._fnCalculateEnd(oSettings);
}
// draw the 'current' page
oSettings.oApi._fnDraw(oSettings);
};

@ -1,33 +0,0 @@
/**
* 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 visible column index into a data
* column index (i.e. all columns regardless of visibility).
*
* 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 fnVisibleToColumnIndex
* @summary Convert a column visible index to a data index.
* @author [Allan Jardine](http://sprymedia.co.uk)
* @deprecated
*
* @param {integer} iMatch Column data index to convert to data index
* @returns {integer} Visible column index
*
* @example
* var table = $('#example').dataTable( {
* aoColumnDefs: [
* { bVisible: false, aTargets: [1] }
* ]
* } );
*
* // This will show 2
* alert( 'Visible Column 1 data index: '+table.fnVisibleToColumnIndex(1) );
*/
jQuery.fn.dataTableExt.oApi.fnVisibleToColumnIndex = function ( oSettings, iMatch )
{
return oSettings.oApi._fnVisibleToColumnIndex( oSettings, iMatch );
};
Loading…
Cancel
Save