From b5ca536b63c285484b49b20689d1d6599bf0469a Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Fri, 8 Mar 2024 09:26:03 +0000 Subject: [PATCH] Removed: Legacy API methods are no longer available in DataTables 2 This commit removes the plug-ins that were DataTables 1 specific --- api/fnAddDataAndDisplay.js | 63 --------------------- api/fnAddTr.js | 74 ------------------------ api/fnColumnIndexToVisible.js | 33 ----------- api/fnDataUpdate.js | 25 --------- api/fnDisplayRow.js | 46 --------------- api/fnDisplayStart.js | 32 ----------- api/fnFakeRowspan.js | 66 ---------------------- api/fnFilterAll.js | 39 ------------- api/fnFilterClear.js | 63 --------------------- api/fnFilterOnReturn.js | 36 ------------ api/fnFindCellRowIndexes.js | 55 ------------------ api/fnFindCellRowNodes.js | 55 ------------------ api/fnGetAdjacentTr.js | 55 ------------------ api/fnGetColumnData.js | 83 --------------------------- api/fnGetColumnIndex.js | 31 ----------- api/fnGetHiddenNodes.js | 43 -------------- api/fnGetTd.js | 59 -------------------- api/fnGetTds.js | 65 ---------------------- api/fnLengthChange.js | 48 ---------------- api/fnMultiFilter.js | 63 --------------------- api/fnPagingInfo.js | 39 ------------- api/fnProcessingIndicator.js | 26 --------- api/fnReloadAjax.js | 102 ---------------------------------- api/fnSetFilteringDelay.js | 56 ------------------- api/fnSortNeutral.js | 36 ------------ api/fnStandingRedraw.js | 35 ------------ api/fnVisibleToColumnIndex.js | 33 ----------- 27 files changed, 1361 deletions(-) delete mode 100644 api/fnAddDataAndDisplay.js delete mode 100644 api/fnAddTr.js delete mode 100644 api/fnColumnIndexToVisible.js delete mode 100644 api/fnDataUpdate.js delete mode 100644 api/fnDisplayRow.js delete mode 100644 api/fnDisplayStart.js delete mode 100644 api/fnFakeRowspan.js delete mode 100644 api/fnFilterAll.js delete mode 100644 api/fnFilterClear.js delete mode 100644 api/fnFilterOnReturn.js delete mode 100644 api/fnFindCellRowIndexes.js delete mode 100644 api/fnFindCellRowNodes.js delete mode 100644 api/fnGetAdjacentTr.js delete mode 100644 api/fnGetColumnData.js delete mode 100644 api/fnGetColumnIndex.js delete mode 100644 api/fnGetHiddenNodes.js delete mode 100644 api/fnGetTd.js delete mode 100644 api/fnGetTds.js delete mode 100644 api/fnLengthChange.js delete mode 100644 api/fnMultiFilter.js delete mode 100644 api/fnPagingInfo.js delete mode 100644 api/fnProcessingIndicator.js delete mode 100644 api/fnReloadAjax.js delete mode 100644 api/fnSetFilteringDelay.js delete mode 100644 api/fnSortNeutral.js delete mode 100644 api/fnStandingRedraw.js delete mode 100644 api/fnVisibleToColumnIndex.js diff --git a/api/fnAddDataAndDisplay.js b/api/fnAddDataAndDisplay.js deleted file mode 100644 index 44416586..00000000 --- a/api/fnAddDataAndDisplay.js +++ /dev/null @@ -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= 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 - }; -}; diff --git a/api/fnAddTr.js b/api/fnAddTr.js deleted file mode 100644 index 594d8e40..00000000 --- a/api/fnAddTr.js +++ /dev/null @@ -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( $(''+ - * '1'+ - * '2'+ - * '3'+ - * '')[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= 0 ; i-- ) - { - oSettings.aoData[iIndex]._anHidden[ i ] = nTds[aInvisible[i]]; - nTr.removeChild( nTds[aInvisible[i]] ); - } - - // Redraw - if ( bRedraw ) - { - this.oApi._fnReDraw( oSettings ); - } -}; diff --git a/api/fnColumnIndexToVisible.js b/api/fnColumnIndexToVisible.js deleted file mode 100644 index 2e106ec1..00000000 --- a/api/fnColumnIndexToVisible.js +++ /dev/null @@ -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 ); -}; diff --git a/api/fnDataUpdate.js b/api/fnDataUpdate.js deleted file mode 100644 index 371e3668..00000000 --- a/api/fnDataUpdate.js +++ /dev/null @@ -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() ); - } ); -}; diff --git a/api/fnDisplayRow.js b/api/fnDisplayRow.js deleted file mode 100644 index ce478344..00000000 --- a/api/fnDisplayRow.js +++ /dev/null @@ -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= 0 ) - { - oSettings._iDisplayStart = ( Math.floor(i / oSettings._iDisplayLength) ) * oSettings._iDisplayLength; - if ( this.oApi._fnCalculateEnd ) { - this.oApi._fnCalculateEnd( oSettings ); - } - } - - this.oApi._fnDraw( oSettings ); -}; diff --git a/api/fnDisplayStart.js b/api/fnDisplayStart.js deleted file mode 100644 index 4bb273bf..00000000 --- a/api/fnDisplayStart.js +++ /dev/null @@ -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 ); - } -}; diff --git a/api/fnFakeRowspan.js b/api/fnFakeRowspan.js deleted file mode 100644 index e3d9f48b..00000000 --- a/api/fnFakeRowspan.js +++ /dev/null @@ -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; -}; diff --git a/api/fnFilterAll.js b/api/fnFilterAll.js deleted file mode 100644 index 6a4cf92c..00000000 --- a/api/fnFilterAll.js +++ /dev/null @@ -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= 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; -}; diff --git a/api/fnGetColumnData.js b/api/fnGetColumnData.js deleted file mode 100644 index 5d62cdf6..00000000 --- a/api/fnGetColumnData.js +++ /dev/null @@ -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 -1) { - continue; - } - - // else push the value onto the result data array - else { - asResultData.push(sValue); - } - } - - return asResultData; -}; diff --git a/api/fnGetColumnIndex.js b/api/fnGetColumnIndex.js deleted file mode 100644 index d48c29aa..00000000 --- a/api/fnGetColumnIndex.js +++ /dev/null @@ -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