1D array of data - add a single row with the data provided
- *
2D array of arrays - add multiple rows in a single call
- *
object - data object when using mData
- *
array of objects - multiple data objects when using mData
- *
- * @param {bool} [redraw=true] redraw the table or not
- * @returns {array} An array of integers, representing the list of indexes in
- * aoData ({@link DataTable.models.oSettings}) that have been added to
- * the table.
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * // Global var for counter
- * var giCount = 2;
- *
- * $(document).ready(function() {
- * $('#example').dataTable();
- * } );
- *
- * function fnClickAddRow() {
- * $('#example').dataTable().fnAddData( [
- * giCount+".1",
- * giCount+".2",
- * giCount+".3",
- * giCount+".4" ]
- * );
- *
- * giCount++;
- * }
- */
- this.fnAddData = function( data, redraw )
- {
- var api = this.api( true );
-
- /* Check if we want to add multiple rows or not */
- var rows = Array.isArray(data) && ( Array.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
- api.rows.add( data ) :
- api.row.add( data );
-
- if ( redraw === undefined || redraw ) {
- api.draw();
- }
-
- return rows.flatten().toArray();
- };
-
-
- /**
- * This function will make DataTables recalculate the column sizes, based on the data
- * contained in the table and the sizes applied to the columns (in the DOM, CSS or
- * through the sWidth parameter). This can be useful when the width of the table's
- * parent element changes (for example a window resize).
- * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable( {
- * "sScrollY": "200px",
- * "bPaginate": false
- * } );
- *
- * $(window).on('resize', function () {
- * oTable.fnAdjustColumnSizing();
- * } );
- * } );
- */
- this.fnAdjustColumnSizing = function ( bRedraw )
- {
- var api = this.api( true ).columns.adjust();
- var settings = api.settings()[0];
- var scroll = settings.oScroll;
-
- if ( bRedraw === undefined || bRedraw ) {
- api.draw( false );
- }
- else if ( scroll.sX !== "" || scroll.sY !== "" ) {
- /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
- _fnScrollDraw( settings );
- }
- };
-
-
- /**
- * Quickly and simply clear a table
- * @param {bool} [bRedraw=true] redraw the table or not
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- *
- * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
- * oTable.fnClearTable();
- * } );
- */
- this.fnClearTable = function( bRedraw )
- {
- var api = this.api( true ).clear();
-
- if ( bRedraw === undefined || bRedraw ) {
- api.draw();
- }
- };
-
-
- /**
- * The exact opposite of 'opening' a row, this function will close any rows which
- * are currently 'open'.
- * @param {node} nTr the table row to 'close'
- * @returns {int} 0 on success, or 1 if failed (can't find the row)
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable;
- *
- * // 'open' an information row when a row is clicked on
- * $('#example tbody tr').click( function () {
- * if ( oTable.fnIsOpen(this) ) {
- * oTable.fnClose( this );
- * } else {
- * oTable.fnOpen( this, "Temporary row opened", "info_row" );
- * }
- * } );
- *
- * oTable = $('#example').dataTable();
- * } );
- */
- this.fnClose = function( nTr )
+ var _that = this;
+ var emptyInit = options === undefined;
+ var len = this.length;
+
+ if ( emptyInit ) {
+ options = {};
+ }
+
+ // Method to get DT API instance from jQuery object
+ this.api = function ()
{
- this.api( true ).row( nTr ).child.hide();
+ return new _Api( this );
};
-
-
- /**
- * Remove a row for the table
- * @param {mixed} target The index of the row from aoData to be deleted, or
- * the TR element you want to delete
- * @param {function|null} [callBack] Callback function
- * @param {bool} [redraw=true] Redraw the table or not
- * @returns {array} The row that was deleted
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- *
- * // Immediately remove the first row
- * oTable.fnDeleteRow( 0 );
- * } );
- */
- this.fnDeleteRow = function( target, callback, redraw )
- {
- var api = this.api( true );
- var rows = api.rows( target );
- var settings = rows.settings()[0];
- var data = settings.aoData[ rows[0][0] ];
-
- rows.remove();
-
- if ( callback ) {
- callback.call( this, settings, data );
+
+ this.each(function() {
+ // For each initialisation we want to give it a clean initialisation
+ // object that can be bashed around
+ var o = {};
+ var oInit = len > 1 ? // optimisation for single table case
+ _fnExtend( o, options, true ) :
+ options;
+
+
+ var i=0, iLen;
+ var sId = this.getAttribute( 'id' );
+ var bInitHandedOff = false;
+ var defaults = DataTable.defaults;
+ var $this = $(this);
+
+
+ /* Sanity check */
+ if ( this.nodeName.toLowerCase() != 'table' )
+ {
+ _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
+ return;
}
-
- if ( redraw === undefined || redraw ) {
- api.draw();
+
+ $(this).trigger( 'options.dt', oInit );
+
+ /* Backwards compatibility for the defaults */
+ _fnCompatOpts( defaults );
+ _fnCompatCols( defaults.column );
+
+ /* Convert the camel-case defaults to Hungarian */
+ _fnCamelToHungarian( defaults, defaults, true );
+ _fnCamelToHungarian( defaults.column, defaults.column, true );
+
+ /* Setting up the initialisation object */
+ _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ), true );
+
+
+
+ /* Check to see if we are re-initialising a table */
+ var allSettings = DataTable.settings;
+ for ( i=0, iLen=allSettings.length ; i').prependTo(this),
+ fastData: function (row, column, type) {
+ return _fnGetCellData(oSettings, row, column, type);
+ }
+ } );
+ oSettings.nTable = this;
+ oSettings.oInit = oInit;
+
+ allSettings.push( oSettings );
+
+ // Make a single API instance available for internal handling
+ oSettings.api = new _Api( oSettings );
+
+ // Need to add the instance after the instance after the settings object has been added
+ // to the settings array, so we can self reference the table instance if more than one
+ oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
+
+ // Backwards compatibility, before we apply all the defaults
+ _fnCompatOpts( oInit );
+
+ // If the length menu is given, but the init display length is not, use the length menu
+ if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
+ {
+ oInit.iDisplayLength = Array.isArray(oInit.aLengthMenu[0])
+ ? oInit.aLengthMenu[0][0]
+ : $.isPlainObject( oInit.aLengthMenu[0] )
+ ? oInit.aLengthMenu[0].value
+ : oInit.aLengthMenu[0];
}
-
- api.draw();
- };
-
-
- /**
- * Get the data for the whole table, an individual row or an individual cell based on the
- * provided parameters.
- * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
- * a TR node then the data source for the whole row will be returned. If given as a
- * TD/TH cell node then iCol will be automatically calculated and the data for the
- * cell returned. If given as an integer, then this is treated as the aoData internal
- * data index for the row (see fnGetPosition) and the data for that row used.
- * @param {int} [col] Optional column index that you want the data of.
- * @returns {array|object|string} If mRow is undefined, then the data for all rows is
- * returned. If mRow is defined, just data for that row, and is iCol is
- * defined, only data for the designated cell is returned.
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * // Row data
- * $(document).ready(function() {
- * oTable = $('#example').dataTable();
- *
- * oTable.$('tr').click( function () {
- * var data = oTable.fnGetData( this );
- * // ... do something with the array / object of data for the row
- * } );
- * } );
- *
- * @example
- * // Individual cell data
- * $(document).ready(function() {
- * oTable = $('#example').dataTable();
- *
- * oTable.$('td').click( function () {
- * var sData = oTable.fnGetData( this );
- * alert( 'The cell clicked on had the value of '+sData );
- * } );
- * } );
- */
- this.fnGetData = function( src, col )
- {
- var api = this.api( true );
-
- if ( src !== undefined ) {
- var type = src.nodeName ? src.nodeName.toLowerCase() : '';
-
- return col !== undefined || type == 'td' || type == 'th' ?
- api.cell( src, col ).data() :
- api.row( src ).data() || null;
- }
-
- return api.data().toArray();
- };
-
-
- /**
- * Get an array of the TR nodes that are used in the table's body. Note that you will
- * typically want to use the '$' API method in preference to this as it is more
- * flexible.
- * @param {int} [iRow] Optional row index for the TR element you want
- * @returns {array|node} If iRow is undefined, returns an array of all TR elements
- * in the table's body, or iRow is defined, just the TR element requested.
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- *
- * // Get the nodes from the table
- * var nNodes = oTable.fnGetNodes( );
- * } );
- */
- this.fnGetNodes = function( iRow )
- {
- var api = this.api( true );
-
- return iRow !== undefined ?
- api.row( iRow ).node() :
- api.rows().nodes().flatten().toArray();
- };
-
-
- /**
- * Get the array indexes of a particular cell from it's DOM element
- * and column index including hidden columns
- * @param {node} node this can either be a TR, TD or TH in the table's body
- * @returns {int} If nNode is given as a TR, then a single index is returned, or
- * if given as a cell, an array of [row index, column index (visible),
- * column index (all)] is given.
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * $('#example tbody td').click( function () {
- * // Get the position of the current data from the node
- * var aPos = oTable.fnGetPosition( this );
- *
- * // Get the data array for this row
- * var aData = oTable.fnGetData( aPos[0] );
- *
- * // Update the data array and return the value
- * aData[ aPos[1] ] = 'clicked';
- * this.innerHTML = 'clicked';
- * } );
- *
- * // Init DataTables
- * oTable = $('#example').dataTable();
- * } );
- */
- this.fnGetPosition = function( node )
- {
- var api = this.api( true );
- var nodeName = node.nodeName.toUpperCase();
-
- if ( nodeName == 'TR' ) {
- return api.row( node ).index();
- }
- else if ( nodeName == 'TD' || nodeName == 'TH' ) {
- var cell = api.cell( node ).index();
-
- return [
- cell.row,
- cell.columnVisible,
- cell.column
- ];
- }
- return null;
- };
-
-
- /**
- * Check to see if a row is 'open' or not.
- * @param {node} nTr the table row to check
- * @returns {boolean} true if the row is currently open, false otherwise
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable;
- *
- * // 'open' an information row when a row is clicked on
- * $('#example tbody tr').click( function () {
- * if ( oTable.fnIsOpen(this) ) {
- * oTable.fnClose( this );
- * } else {
- * oTable.fnOpen( this, "Temporary row opened", "info_row" );
- * }
- * } );
- *
- * oTable = $('#example').dataTable();
- * } );
- */
- this.fnIsOpen = function( nTr )
- {
- return this.api( true ).row( nTr ).child.isShown();
- };
-
-
- /**
- * This function will place a new row directly after a row which is currently
- * on display on the page, with the HTML contents that is passed into the
- * function. This can be used, for example, to ask for confirmation that a
- * particular record should be deleted.
- * @param {node} nTr The table row to 'open'
- * @param {string|node|jQuery} mHtml The HTML to put into the row
- * @param {string} sClass Class to give the new TD cell
- * @returns {node} The row opened. Note that if the table row passed in as the
- * first parameter, is not found in the table, this method will silently
- * return.
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable;
- *
- * // 'open' an information row when a row is clicked on
- * $('#example tbody tr').click( function () {
- * if ( oTable.fnIsOpen(this) ) {
- * oTable.fnClose( this );
- * } else {
- * oTable.fnOpen( this, "Temporary row opened", "info_row" );
- * }
- * } );
- *
- * oTable = $('#example').dataTable();
- * } );
- */
- this.fnOpen = function( nTr, mHtml, sClass )
- {
- return this.api( true )
- .row( nTr )
- .child( mHtml, sClass )
- .show()
- .child()[0];
- };
-
-
- /**
- * Change the pagination - provides the internal logic for pagination in a simple API
- * function. With this function you can have a DataTables table go to the next,
- * previous, first or last pages.
- * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
- * or page number to jump to (integer), note that page 0 is the first page.
- * @param {bool} [bRedraw=true] Redraw the table or not
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- * oTable.fnPageChange( 'next' );
- * } );
- */
- this.fnPageChange = function ( mAction, bRedraw )
- {
- var api = this.api( true ).page( mAction );
-
- if ( bRedraw === undefined || bRedraw ) {
- api.draw(false);
- }
- };
-
-
- /**
- * Show a particular column
- * @param {int} iCol The column whose display should be changed
- * @param {bool} bShow Show (true) or hide (false) the column
- * @param {bool} [bRedraw=true] Redraw the table or not
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- *
- * // Hide the second column after initialisation
- * oTable.fnSetColumnVis( 1, false );
- * } );
- */
- this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
- {
- var api = this.api( true ).column( iCol ).visible( bShow );
-
- if ( bRedraw === undefined || bRedraw ) {
- api.columns.adjust().draw();
- }
- };
-
-
- /**
- * Get the settings for a particular table for external manipulation
- * @returns {object} DataTables settings object. See
- * {@link DataTable.models.oSettings}
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- * var oSettings = oTable.fnSettings();
- *
- * // Show an example parameter from the settings
- * alert( oSettings._iDisplayStart );
- * } );
- */
- this.fnSettings = function()
- {
- return _fnSettingsFromNode( this[_ext.iApiIndex] );
- };
-
-
- /**
- * Sort the table by a particular column
- * @param {int} iCol the data index to sort on. Note that this will not match the
- * 'display index' if you have hidden data entries
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- *
- * // Sort immediately with columns 0 and 1
- * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
- * } );
- */
- this.fnSort = function( aaSort )
- {
- this.api( true ).order( aaSort ).draw();
- };
-
-
- /**
- * Attach a sort listener to an element for a given column
- * @param {node} nNode the element to attach the sort listener to
- * @param {int} iColumn the column that a click on this node will sort on
- * @param {function} [fnCallback] callback function when sort is run
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- *
- * // Sort on column 1, when 'sorter' is clicked on
- * oTable.fnSortListener( document.getElementById('sorter'), 1 );
- * } );
- */
- this.fnSortListener = function( nNode, iColumn, fnCallback )
- {
- this.api( true ).order.listener( nNode, iColumn, fnCallback );
- };
-
-
- /**
- * Update a table cell or row - this method will accept either a single value to
- * update the cell with, an array of values with one element for each column or
- * an object in the same format as the original data source. The function is
- * self-referencing in order to make the multi column updates easier.
- * @param {object|array|string} mData Data to update the cell/row with
- * @param {node|int} mRow TR element you want to update or the aoData index
- * @param {int} [iColumn] The column to update, give as null or undefined to
- * update a whole row.
- * @param {bool} [bRedraw=true] Redraw the table or not
- * @param {bool} [bAction=true] Perform pre-draw actions or not
- * @returns {int} 0 on success, 1 on error
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
- * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
- * } );
- */
- this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
- {
- var api = this.api( true );
-
- if ( iColumn === undefined || iColumn === null ) {
- api.row( mRow ).data( mData );
- }
- else {
- api.cell( mRow, iColumn ).data( mData );
- }
-
- if ( bAction === undefined || bAction ) {
- api.columns.adjust();
- }
-
- if ( bRedraw === undefined || bRedraw ) {
- api.draw();
- }
- return 0;
- };
-
-
- /**
- * Provide a common method for plug-ins to check the version of DataTables being used, in order
- * to ensure compatibility.
- * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
- * formats "X" and "X.Y" are also acceptable.
- * @returns {boolean} true if this version of DataTables is greater or equal to the required
- * version, or false if this version of DataTales is not suitable
- * @method
- * @dtopt API
- * @deprecated Since v1.10
- *
- * @example
- * $(document).ready(function() {
- * var oTable = $('#example').dataTable();
- * alert( oTable.fnVersionCheck( '1.9.0' ) );
- * } );
- */
- this.fnVersionCheck = _ext.fnVersionCheck;
-
-
- var _that = this;
- var emptyInit = options === undefined;
- var len = this.length;
-
- if ( emptyInit ) {
- options = {};
- }
-
- this.oApi = this.internal = _ext.internal;
-
- // Extend with old style plug-in API methods
- for ( var fn in DataTable.ext.internal ) {
- if ( fn ) {
- this[fn] = _fnExternApiFunc(fn);
- }
- }
-
- this.each(function() {
- // For each initialisation we want to give it a clean initialisation
- // object that can be bashed around
- var o = {};
- var oInit = len > 1 ? // optimisation for single table case
- _fnExtend( o, options, true ) :
- options;
-
- /*global oInit,_that,emptyInit*/
- var i=0, iLen, j, jLen, k, kLen;
- var sId = this.getAttribute( 'id' );
- var bInitHandedOff = false;
- var defaults = DataTable.defaults;
- var $this = $(this);
+ // Apply the defaults and init options to make a single init object will all
+ // options defined from defaults and instance options.
+ oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
- /* Sanity check */
- if ( this.nodeName.toLowerCase() != 'table' )
- {
- _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
- return;
- }
- /* Backwards compatibility for the defaults */
- _fnCompatOpts( defaults );
- _fnCompatCols( defaults.column );
+ // Map the initialisation options onto the settings object
+ _fnMap( oSettings.oFeatures, oInit, [
+ "bPaginate",
+ "bLengthChange",
+ "bFilter",
+ "bSort",
+ "bSortMulti",
+ "bInfo",
+ "bProcessing",
+ "bAutoWidth",
+ "bSortClasses",
+ "bServerSide",
+ "bDeferRender"
+ ] );
+ _fnMap( oSettings, oInit, [
+ "ajax",
+ "fnFormatNumber",
+ "sServerMethod",
+ "aaSorting",
+ "aaSortingFixed",
+ "aLengthMenu",
+ "sPaginationType",
+ "iStateDuration",
+ "bSortCellsTop",
+ "iTabIndex",
+ "sDom",
+ "fnStateLoadCallback",
+ "fnStateSaveCallback",
+ "renderer",
+ "searchDelay",
+ "rowId",
+ "caption",
+ "layout",
+ [ "iCookieDuration", "iStateDuration" ], // backwards compat
+ [ "oSearch", "oPreviousSearch" ],
+ [ "aoSearchCols", "aoPreSearchCols" ],
+ [ "iDisplayLength", "_iDisplayLength" ]
+ ] );
+ _fnMap( oSettings.oScroll, oInit, [
+ [ "sScrollX", "sX" ],
+ [ "sScrollXInner", "sXInner" ],
+ [ "sScrollY", "sY" ],
+ [ "bScrollCollapse", "bCollapse" ]
+ ] );
+ _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
- /* Convert the camel-case defaults to Hungarian */
- _fnCamelToHungarian( defaults, defaults, true );
- _fnCamelToHungarian( defaults.column, defaults.column, true );
+ /* Callback functions which are array driven */
+ _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback );
+ _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams );
+ _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams );
+ _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded );
+ _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback );
+ _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow );
+ _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback );
+ _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback );
+ _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete );
+ _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback );
- /* Setting up the initialisation object */
- _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ), true );
+ oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
+ /* Browser support detection */
+ _fnBrowserDetect( oSettings );
+ var oClasses = oSettings.oClasses;
- /* Check to see if we are re-initialising a table */
- var allSettings = DataTable.settings;
- for ( i=0, iLen=allSettings.length ; i').appendTo($this);
- }
- oSettings.nTHead = thead[0];
-
- var tbody = $this.children('tbody');
- if ( tbody.length === 0 ) {
- tbody = $('').insertAfter(thead);
- }
- oSettings.nTBody = tbody[0];
-
- var tfoot = $this.children('tfoot');
- if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) {
- // If we are a scrolling table, and no footer has been given, then we need to create
- // a tfoot element for the caption element to be appended to
- tfoot = $('').appendTo($this);
- }
-
- if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
- $this.addClass( oClasses.sNoFooter );
- }
- else if ( tfoot.length > 0 ) {
- oSettings.nTFoot = tfoot[0];
- _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
- }
-
- /* Check if there is data passing into the constructor */
- if ( oInit.aaData ) {
- for ( i=0 ; i').appendTo( $this );
+ }
+
+ caption.html( oSettings.caption );
+ }
+
+ // Store the caption side, so we can remove the element from the document
+ // when creating the element
+ if (caption.length) {
+ caption[0]._captionSide = caption.css('caption-side');
+ oSettings.captionNode = caption[0];
+ }
+
+ if ( thead.length === 0 ) {
+ thead = $('').appendTo($this);
+ }
+ oSettings.nTHead = thead[0];
+ $('tr', thead).addClass(oClasses.thead.row);
+
+ var tbody = $this.children('tbody');
+ if ( tbody.length === 0 ) {
+ tbody = $('').insertAfter(thead);
+ }
+ oSettings.nTBody = tbody[0];
+
+ var tfoot = $this.children('tfoot');
+ if ( tfoot.length === 0 ) {
+ // If we are a scrolling table, and no footer has been given, then we need to create
+ // a tfoot element for the caption element to be appended to
+ tfoot = $('').appendTo($this);
+ }
+ oSettings.nTFoot = tfoot[0];
+ $('tr', tfoot).addClass(oClasses.tfoot.row);
+
+ // Check if there is data passing into the constructor
+ if ( oInit.aaData ) {
+ for ( i=0 ; iafnSortData
+ * for searching data.
+ *
+ * The functions defined take a single parameter:
+ *
+ * 1. `{*}` Data from the column cell to be prepared for searching
+ *
+ * Each function is expected to return:
+ *
+ * * `{string|null}` Formatted string that will be used for the searching.
+ *
+ * @type object
+ * @default {}
+ *
+ * @example
+ * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
+ * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
+ * }
+ */
+ search: {},
+
+
+ /**
+ * Type based ordering.
+ *
+ * The column type tells DataTables what ordering to apply to the table
+ * when a column is sorted upon. The order for each type that is defined,
+ * is defined by the functions available in this object.
+ *
+ * Each ordering option can be described by three properties added to
+ * this object:
+ *
+ * * `{type}-pre` - Pre-formatting function
+ * * `{type}-asc` - Ascending order function
+ * * `{type}-desc` - Descending order function
+ *
+ * All three can be used together, only `{type}-pre` or only
+ * `{type}-asc` and `{type}-desc` together. It is generally recommended
+ * that only `{type}-pre` is used, as this provides the optimal
+ * implementation in terms of speed, although the others are provided
+ * for compatibility with existing Javascript sort functions.
+ *
+ * `{type}-pre`: Functions defined take a single parameter:
+ *
+ * 1. `{*}` Data from the column cell to be prepared for ordering
+ *
+ * And return:
+ *
+ * * `{*}` Data to be sorted upon
+ *
+ * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
+ * functions, taking two parameters:
+ *
+ * 1. `{*}` Data to compare to the second parameter
+ * 2. `{*}` Data to compare to the first parameter
+ *
+ * And returning:
+ *
+ * * `{*}` Ordering match: <0 if first parameter should be sorted lower
+ * than the second parameter, ===0 if the two parameters are equal and
+ * >0 if the first parameter should be sorted height than the second
+ * parameter.
+ *
+ * @type object
+ * @default {}
+ *
+ * @example
+ * // Numeric ordering of formatted numbers with a pre-formatter
+ * $.extend( $.fn.dataTable.ext.type.order, {
+ * "string-pre": function(x) {
+ * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
+ * return parseFloat( a );
+ * }
+ * } );
+ *
+ * @example
+ * // Case-sensitive string ordering, with no pre-formatting method
+ * $.extend( $.fn.dataTable.ext.order, {
+ * "string-case-asc": function(x,y) {
+ * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
+ * },
+ * "string-case-desc": function(x,y) {
+ * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
+ * }
+ * } );
+ */
+ order: {}
+ },
+
+ /**
+ * Unique DataTables instance counter
+ *
+ * @type int
+ * @private
+ */
+ _unique: 0,
+
+
+ //
+ // Depreciated
+ // The following properties are retained for backwards compatibility only.
+ // The should not be used in new projects and will be removed in a future
+ // version
+ //
+
+ /**
+ * Version check function.
+ * @type function
+ * @depreciated Since 1.10
+ */
+ fnVersionCheck: DataTable.fnVersionCheck,
+
+
+ /**
+ * Index for what 'this' index API functions should use
+ * @type int
+ * @deprecated Since v1.10
+ */
+ iApiIndex: 0,
+
+
+ /**
+ * Software version
+ * @type string
+ * @deprecated Since v1.10
+ */
+ sVersion: DataTable.version
};
+ //
+ // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
+ //
+ $.extend( _ext, {
+ afnFiltering: _ext.search,
+ aTypes: _ext.type.detect,
+ ofnSearch: _ext.type.search,
+ oSort: _ext.type.order,
+ afnSortData: _ext.order,
+ aoFeatures: _ext.feature,
+ oStdClasses: _ext.classes,
+ oPagination: _ext.pager
+ } );
+
+
+ $.extend( DataTable.ext.classes, {
+ container: 'dt-container',
+ empty: {
+ row: 'dt-empty'
+ },
+ info: {
+ container: 'dt-info'
+ },
+ length: {
+ container: 'dt-length',
+ select: 'dt-input'
+ },
+ order: {
+ canAsc: 'dt-orderable-asc',
+ canDesc: 'dt-orderable-desc',
+ isAsc: 'dt-ordering-asc',
+ isDesc: 'dt-ordering-desc',
+ none: 'dt-orderable-none',
+ position: 'sorting_'
+ },
+ processing: {
+ container: 'dt-processing'
+ },
+ scrolling: {
+ body: 'dt-scroll-body',
+ container: 'dt-scroll',
+ footer: {
+ self: 'dt-scroll-foot',
+ inner: 'dt-scroll-footInner'
+ },
+ header: {
+ self: 'dt-scroll-head',
+ inner: 'dt-scroll-headInner'
+ }
+ },
+ search: {
+ container: 'dt-search',
+ input: 'dt-input'
+ },
+ table: 'dataTable',
+ tbody: {
+ cell: '',
+ row: ''
+ },
+ thead: {
+ cell: '',
+ row: ''
+ },
+ tfoot: {
+ cell: '',
+ row: ''
+ },
+ paging: {
+ active: 'current',
+ button: 'dt-paging-button',
+ container: 'dt-paging',
+ disabled: 'disabled'
+ }
+ } );
+
+
/*
* It is useful to have variables which are scoped locally so only the
* DataTables functions can access them and they don't leak into global space.
@@ -1338,7 +1099,6 @@
// Defined else where
// _selector_run
// _selector_opts
- // _selector_first
// _selector_row_indexes
var _ext; // DataTable.ext
@@ -1352,12 +1112,12 @@
// This is not strict ISO8601 - Date.parse() is quite lax, although
// implementations differ between browsers.
- var _re_date = /^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/;
+ var _re_date = /^\d{2,4}[./-]\d{1,2}[./-]\d{1,2}([T ]{1}\d{1,2}[:.]\d{2}([.:]\d{2})?)?$/;
// Escape regular expression special characters
var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
- // http://en.wikipedia.org/wiki/Foreign_exchange_market
+ // https://en.wikipedia.org/wiki/Foreign_exchange_market
// - \u20BD - Russian ruble.
// - \u20a9 - South Korean Won
// - \u20BA - Turkish Lira
@@ -1427,12 +1187,17 @@
return _empty( d ) || typeof d === 'string';
};
-
+ // Is a string a number surrounded by HTML?
var _htmlNumeric = function ( d, decimalPoint, formatted ) {
if ( _empty( d ) ) {
return true;
}
+ // input and select strings mean that this isn't just a number
+ if (typeof d === 'string' && d.match(/<(input|select)/i)) {
+ return null;
+ }
+
var html = _isHtml( d );
return ! html ?
null :
@@ -1485,7 +1250,9 @@
}
else {
for ( ; i/g, '>')
+ .replace(/"/g, '"') :
+ d;
+ };
+
+ // Remove diacritics from a string by decomposing it and then removing
+ // non-ascii characters
+ var _normalize = function (str, both) {
+ if (typeof str !== 'string') {
+ return str;
+ }
+
+ // It is faster to just run `normalize` than it is to check if
+ // we need to with a regex!
+ var res = str.normalize("NFD");
+
+ // Equally, here we check if a regex is needed or not
+ return res.length !== str.length
+ ? (both === true ? str + ' ' : '' ) + res.replace(/[\u0300-\u036f]/g, "")
+ : res;
+ }
/**
* Determine if all values in the array are unique. This means we can short
@@ -1574,13 +1372,17 @@
*/
var _unique = function ( src )
{
+ if (Array.from && Set) {
+ return Array.from(new Set(src));
+ }
+
if ( _areAllUnique( src ) ) {
return src.slice();
}
// A faster unique method is to use object keys to identify used values,
// but this doesn't work with arrays or objects, which we must also
- // consider. See jsperf.com/compare-array-unique-versions/4 for more
+ // consider. See jsperf.app/compare-array-unique-versions/4 for more
// information.
var
out = [],
@@ -1615,40 +1417,20 @@
else {
out.push(val);
}
-
+
return out;
}
- var _includes = function (search, start) {
- if (start === undefined) {
- start = 0;
+ // Similar to jQuery's addClass, but use classList.add
+ function _addClass(el, name) {
+ if (name) {
+ name.split(' ').forEach(function (n) {
+ if (n) {
+ // `add` does deduplication, so no need to check `contains`
+ el.classList.add(n);
+ }
+ });
}
-
- return this.indexOf(search, start) !== -1;
- };
-
- // Array.isArray polyfill.
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
- if (! Array.isArray) {
- Array.isArray = function(arg) {
- return Object.prototype.toString.call(arg) === '[object Array]';
- };
- }
-
- if (! Array.prototype.includes) {
- Array.prototype.includes = _includes;
- }
-
- // .trim() polyfill
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
- if (!String.prototype.trim) {
- String.prototype.trim = function () {
- return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
- };
- }
-
- if (! String.prototype.includes) {
- String.prototype.includes = _includes;
}
/**
@@ -1662,6 +1444,43 @@
* @namespace
*/
DataTable.util = {
+ /**
+ * Return a string with diacritic characters decomposed
+ * @param {*} mixed Function or string to normalize
+ * @param {*} both Return original string and the normalized string
+ * @returns String or undefined
+ */
+ diacritics: function (mixed, both) {
+ var type = typeof mixed;
+
+ if (type !== 'function') {
+ return _normalize(mixed, both);
+ }
+ _normalize = mixed;
+ },
+
+ /**
+ * Debounce a function
+ *
+ * @param {function} fn Function to be called
+ * @param {integer} freq Call frequency in mS
+ * @return {function} Wrapped function
+ */
+ debounce: function ( fn, timeout ) {
+ var timer;
+
+ return function () {
+ var that = this;
+ var args = arguments;
+
+ clearTimeout(timer);
+
+ timer = setTimeout( function () {
+ fn.apply(that, args);
+ }, timeout || 250 );
+ };
+ },
+
/**
* Throttle the calls to a function. Arguments and context are maintained
* for the throttled function.
@@ -1697,7 +1516,6 @@
};
},
-
/**
* Escape a string such that it can be used in a regular expression
*
@@ -1731,9 +1549,10 @@
source( data, 'set', val, meta );
};
}
- else if ( typeof source === 'string' && (source.indexOf('.') !== -1 ||
- source.indexOf('[') !== -1 || source.indexOf('(') !== -1) )
- {
+ else if (
+ typeof source === 'string' && (source.indexOf('.') !== -1 ||
+ source.indexOf('[') !== -1 || source.indexOf('(') !== -1)
+ ) {
// Like the get, we need to get data from a nested object
var setData = function (data, val, src) {
var a = _fnSplitObjNotation( src ), b;
@@ -1849,9 +1668,10 @@
return source( data, type, row, meta );
};
}
- else if ( typeof source === 'string' && (source.indexOf('.') !== -1 ||
- source.indexOf('[') !== -1 || source.indexOf('(') !== -1) )
- {
+ else if (
+ typeof source === 'string' && (source.indexOf('.') !== -1 ||
+ source.indexOf('[') !== -1 || source.indexOf('(') !== -1)
+ ) {
/* If there is a . in the source string then the data source is in a
* nested object so we loop over the data for each level to get the next
* level down. On each loop we test for undefined, and if found immediately
@@ -1926,11 +1746,39 @@
}
else {
// Array or flat object mapping
- return function (data, type) { // row and meta also passed, but not used
+ return function (data) { // row and meta also passed, but not used
return data[source];
};
}
- }
+ },
+
+ stripHtml: function (mixed) {
+ var type = typeof mixed;
+
+ if (type === 'function') {
+ _stripHtml = mixed;
+ return;
+ }
+ else if (type === 'string') {
+ return _stripHtml(mixed);
+ }
+ return mixed;
+ },
+
+ escapeHtml: function (mixed) {
+ var type = typeof mixed;
+
+ if (type === 'function') {
+ _escapeHtml = mixed;
+ return;
+ }
+ else if (type === 'string' || Array.isArray(mixed)) {
+ return _escapeHtml(mixed);
+ }
+ return mixed;
+ },
+
+ unique: _unique
};
@@ -1950,7 +1798,7 @@
newKey,
map = {};
- $.each( o, function (key, val) {
+ $.each( o, function (key) {
match = key.match(/^([^A-Z]+?)([A-Z])/);
if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
@@ -1988,7 +1836,7 @@
var hungarianKey;
- $.each( user, function (key, val) {
+ $.each( user, function (key) {
hungarianKey = src._hungarianMap[ key ];
if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
@@ -2011,57 +1859,6 @@
} );
}
-
- /**
- * Language compatibility - when certain options are given, and others aren't, we
- * need to duplicate the values over, in order to provide backwards compatibility
- * with older language files.
- * @param {object} oSettings dataTables settings object
- * @memberof DataTable#oApi
- */
- function _fnLanguageCompat( lang )
- {
- // Note the use of the Hungarian notation for the parameters in this method as
- // this is called after the mapping of camelCase to Hungarian
- var defaults = DataTable.defaults.oLanguage;
-
- // Default mapping
- var defaultDecimal = defaults.sDecimal;
- if ( defaultDecimal ) {
- _addNumericSort( defaultDecimal );
- }
-
- if ( lang ) {
- var zeroRecords = lang.sZeroRecords;
-
- // Backwards compatibility - if there is no sEmptyTable given, then use the same as
- // sZeroRecords - assuming that is given.
- if ( ! lang.sEmptyTable && zeroRecords &&
- defaults.sEmptyTable === "No data available in table" )
- {
- _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
- }
-
- // Likewise with loading records
- if ( ! lang.sLoadingRecords && zeroRecords &&
- defaults.sLoadingRecords === "Loading..." )
- {
- _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
- }
-
- // Old parameter name of the thousands separator mapped onto the new
- if ( lang.sInfoThousands ) {
- lang.sThousands = lang.sInfoThousands;
- }
-
- var decimal = lang.sDecimal;
- if ( decimal && defaultDecimal !== decimal ) {
- _addNumericSort( decimal );
- }
- }
- }
-
-
/**
* Map one parameter onto another
* @param {object} o Object to map
@@ -2113,6 +1910,11 @@
}
}
}
+
+ // Enable search delay if server-side processing is enabled
+ if (init.serverSide && ! init.searchDelay) {
+ init.searchDelay = 400;
+ }
}
@@ -2156,7 +1958,7 @@
.css( {
position: 'fixed',
top: 0,
- left: $(window).scrollLeft()*-1, // allow for scrolling
+ left: -1 * window.pageXOffset, // allow for scrolling
height: 1,
width: 1,
overflow: 'hidden'
@@ -2183,31 +1985,13 @@
var outer = n.children();
var inner = outer.children();
- // Numbers below, in order, are:
- // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
- //
- // IE6 XP: 100 100 100 83
- // IE7 Vista: 100 100 100 83
- // IE 8+ Windows: 83 83 100 83
- // Evergreen Windows: 83 83 100 83
- // Evergreen Mac with scrollbars: 85 85 100 85
- // Evergreen Mac without scrollbars: 100 100 100 100
-
// Get scrollbar width
browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
- // IE6/7 will oversize a width 100% element inside a scrolling element, to
- // include the width of the scrollbar, while other browsers ensure the inner
- // element is contained without forcing scrolling
- browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
-
// In rtl text layout, some browsers (most, but not all) will place the
// scrollbar on the left, rather than the right.
browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
- // IE8- don't provide height and width for getBoundingClientRect
- browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
-
n.remove();
}
@@ -2215,58 +1999,22 @@
settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
}
-
- /**
- * Array.prototype reduce[Right] method, used for browsers which don't support
- * JS 1.6. Done this way to reduce code size, since we iterate either way
- * @param {object} settings dataTables settings object
- * @memberof DataTable#oApi
- */
- function _fnReduce ( that, fn, init, start, end, inc )
- {
- var
- i = start,
- value,
- isSet = false;
-
- if ( init !== undefined ) {
- value = init;
- isSet = true;
- }
-
- while ( i !== end ) {
- if ( ! that.hasOwnProperty(i) ) {
- continue;
- }
-
- value = isSet ?
- fn( value, that[i], i, that ) :
- that[i];
-
- isSet = true;
- i += inc;
- }
-
- return value;
- }
-
/**
* Add a column to the list used for the table with default values
* @param {object} oSettings dataTables settings object
- * @param {node} nTh The th element for this column
* @memberof DataTable#oApi
*/
- function _fnAddColumn( oSettings, nTh )
+ function _fnAddColumn( oSettings )
{
// Add column to aoColumns array
var oDefaults = DataTable.defaults.column;
var iCol = oSettings.aoColumns.length;
var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
- "nTh": nTh ? nTh : document.createElement('th'),
- "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
"aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
"mData": oDefaults.mData ? oDefaults.mData : iCol,
- idx: iCol
+ idx: iCol,
+ searchFixed: {},
+ colEl: $('
')
} );
oSettings.aoColumns.push( oCol );
@@ -2275,9 +2023,6 @@
// with only some of the parameters defined, and also not give a default
var searchCols = oSettings.aoPreSearchCols;
searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
-
- // Use the default column options function to initialise classes etc
- _fnColumnOptions( oSettings, iCol, $(nTh).data() );
}
@@ -2291,21 +2036,6 @@
function _fnColumnOptions( oSettings, iCol, oOptions )
{
var oCol = oSettings.aoColumns[ iCol ];
- var oClasses = oSettings.oClasses;
- var th = $(oCol.nTh);
-
- // Try to get width information from the DOM. We can't get it from CSS
- // as we'd need to parse the CSS stylesheet. `width` option can override
- if ( ! oCol.sWidthOrig ) {
- // Width attribute
- oCol.sWidthOrig = th.attr('width') || null;
-
- // Style attribute
- var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
- if ( t ) {
- oCol.sWidthOrig = t[1];
- }
- }
/* User specified column options */
if ( oOptions !== undefined && oOptions !== null )
@@ -2326,16 +2056,13 @@
{
oCol._sManualType = oOptions.sType;
}
-
+
// `class` is a reserved word in Javascript, so we need to provide
// the ability to use a valid name for the camel case input
if ( oOptions.className && ! oOptions.sClass )
{
oOptions.sClass = oOptions.className;
}
- if ( oOptions.sClass ) {
- th.addClass( oOptions.sClass );
- }
var origClass = oCol.sClass;
@@ -2356,18 +2083,22 @@
oCol.aDataSort = [ oOptions.iDataSort ];
}
_fnMap( oCol, oOptions, "aDataSort" );
-
- // Fall back to the aria-label attribute on the table header if no ariaTitle is
- // provided.
- if (! oCol.ariaTitle) {
- oCol.ariaTitle = th.attr("aria-label");
- }
}
/* Cache the data get and set functions for speed */
var mDataSrc = oCol.mData;
var mData = _fnGetObjectDataFn( mDataSrc );
- var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
+
+ // The `render` option can be given as an array to access the helper rendering methods.
+ // The first element is the rendering method to use, the rest are the parameters to pass
+ if ( oCol.mRender && Array.isArray( oCol.mRender ) ) {
+ var copy = oCol.mRender.slice();
+ var name = copy.shift();
+
+ oCol.mRender = DataTable.render[name].apply(window, copy);
+ }
+
+ oCol._render = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
var attrTest = function( src ) {
return typeof src === 'string' && src.indexOf('@') !== -1;
@@ -2380,8 +2111,8 @@
oCol.fnGetData = function (rowData, type, meta) {
var innerData = mData( rowData, type, undefined, meta );
- return mRender && type ?
- mRender( innerData, type, rowData, meta ) :
+ return oCol._render && type ?
+ oCol._render( innerData, type, rowData, meta ) :
innerData;
};
oCol.fnSetData = function ( rowData, val, meta ) {
@@ -2398,31 +2129,6 @@
if ( !oSettings.oFeatures.bSort )
{
oCol.bSortable = false;
- th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
- }
-
- /* Check that the class assignment is correct for sorting */
- var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
- var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
- if ( !oCol.bSortable || (!bAsc && !bDesc) )
- {
- oCol.sSortingClass = oClasses.sSortableNone;
- oCol.sSortingClassJUI = "";
- }
- else if ( bAsc && !bDesc )
- {
- oCol.sSortingClass = oClasses.sSortableAsc;
- oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
- }
- else if ( !bAsc && bDesc )
- {
- oCol.sSortingClass = oClasses.sSortableDesc;
- oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
- }
- else
- {
- oCol.sSortingClass = oClasses.sSortable;
- oCol.sSortingClassJUI = oClasses.sSortJUI;
}
}
@@ -2435,27 +2141,33 @@
*/
function _fnAdjustColumnSizing ( settings )
{
- /* Not interested in doing column width calculation if auto-width is disabled */
- if ( settings.oFeatures.bAutoWidth !== false )
- {
- var columns = settings.aoColumns;
-
- _fnCalculateColumnWidths( settings );
- for ( var i=0 , iLen=columns.length ; i= 0 )
+ var target = aTargets[j];
+
+ if ( typeof target === 'number' && target >= 0 )
{
/* Add columns that we don't yet know about */
- while( columns.length <= aTargets[j] )
+ while( columns.length <= target )
{
_fnAddColumn( oSettings );
}
/* Integer, basic index */
- fn( aTargets[j], def );
+ fn( target, def );
}
- else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
+ else if ( typeof target === 'number' && target < 0 )
{
/* Negative integer, right to left column counting */
- fn( columns.length+aTargets[j], def );
+ fn( columns.length+target, def );
}
- else if ( typeof aTargets[j] === 'string' )
+ else if ( typeof target === 'string' )
{
- /* Class name matching on TH element */
- for ( k=0, kLen=columns.length ; k=0 if successful (index of new aoData entry), -1 if failed
* @memberof DataTable#oApi
*/
- function _fnAddData ( oSettings, aDataIn, nTr, anTds )
+ function _fnAddData ( settings, dataIn, tr, tds )
{
/* Create the object for storing information about this new row */
- var iRow = oSettings.aoData.length;
- var oData = $.extend( true, {}, DataTable.models.oRow, {
- src: nTr ? 'dom' : 'data',
- idx: iRow
+ var rowIdx = settings.aoData.length;
+ var rowModel = $.extend( true, {}, DataTable.models.oRow, {
+ src: tr ? 'dom' : 'data',
+ idx: rowIdx
} );
- oData._aData = aDataIn;
- oSettings.aoData.push( oData );
+ rowModel._aData = dataIn;
+ settings.aoData.push( rowModel );
- /* Create the cells */
- var nTd, sThisType;
- var columns = oSettings.aoColumns;
+ var columns = settings.aoColumns;
- // Invalidate the column types as the new data needs to be revalidated
for ( var i=0, iLen=columns.length ; i iTarget )
- {
- a[i]--;
- }
- }
-
- if ( iTargetIndex != -1 && splice === undefined )
- {
- a.splice( iTargetIndex, 1 );
- }
- }
-
-
/**
* Mark cached data as invalid such that a re-read of the data will occur when
* the cached data is next requested. Also update from the data source object.
@@ -2986,16 +2809,11 @@
{
var row = settings.aoData[ rowIdx ];
var i, ien;
- var cellWrite = function ( cell, col ) {
- // This is very frustrating, but in IE if you just write directly
- // to innerHTML, and elements that are overwritten are GC'ed,
- // even if there is a reference to them elsewhere
- while ( cell.childNodes.length ) {
- cell.removeChild( cell.firstChild );
- }
- cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
- };
+ // Remove the cached data for the row
+ row._aSortData = null;
+ row._aFilterData = null;
+ row.displayData = null;
// Are we reading last data from DOM or the data object?
if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
@@ -3008,33 +2826,34 @@
else {
// Reading from data object, update the DOM
var cells = row.anCells;
+ var display = _fnGetRowDisplay(settings, rowIdx);
if ( cells ) {
if ( colIdx !== undefined ) {
- cellWrite( cells[colIdx], colIdx );
+ _fnWriteCell(cells[colIdx], display[colIdx]);
}
else {
for ( i=0, ien=cells.length ; i').appendTo( thead );
+ var classes = settings.oClasses;
+ var columns = settings.aoColumns;
+ var i, ien, row;
+ var target = side === 'header'
+ ? settings.nTHead
+ : settings.nTFoot;
+ var titleProp = side === 'header' ? 'sTitle' : side;
+
+ // Footer might be defined
+ if (! target) {
+ return;
}
- for ( i=0, ien=columns.length ; i')
+ .appendTo( target );
- if ( createHeader ) {
- cell.appendTo( row );
+ for ( i=0, ien=columns.length ; i')
+ .html( columns[i][titleProp] || '' )
+ .appendTo( row );
}
+ }
- // 1.11 move into sorting
- if ( oSettings.oFeatures.bSort ) {
- cell.addClass( column.sSortingClass );
+ var detected = _fnDetectHeader( settings, target, true );
- if ( column.bSortable !== false ) {
- cell
- .attr( 'tabindex', oSettings.iTabIndex )
- .attr( 'aria-controls', oSettings.sTableId );
+ if (side === 'header') {
+ settings.aoHeader = detected;
+ }
+ else {
+ settings.aoFooter = detected;
+ }
- _fnSortAttachListener( oSettings, column.nTh, i );
- }
- }
+ // ARIA role for the rows
+ $(target).children('tr').attr('role', 'row');
- if ( column.sTitle != cell[0].innerHTML ) {
- cell.html( column.sTitle );
- }
+ // Every cell needs to be passed through the renderer
+ $(target).children('tr').children('th, td')
+ .each( function () {
+ _fnRenderer( settings, side )(
+ settings, $(this), classes
+ );
+ } );
+ }
- _fnRenderer( oSettings, 'header' )(
- oSettings, cell, column, classes
- );
+ /**
+ * Build a layout structure for a header or footer
+ *
+ * @param {*} settings DataTables settings
+ * @param {*} source Source layout array
+ * @param {*} incColumns What columns should be included
+ * @returns Layout array
+ */
+ function _fnHeaderLayout( settings, source, incColumns )
+ {
+ var row, column, cell;
+ var local = [];
+ var structure = [];
+ var columns = settings.aoColumns;
+ var columnCount = columns.length;
+ var rowspan, colspan;
+
+ if ( ! source ) {
+ return;
}
- if ( createHeader ) {
- _fnDetectHeader( oSettings.aoHeader, thead );
+ // Default is to work on only visible columns
+ if ( ! incColumns ) {
+ incColumns = _range(columnCount)
+ .filter(function (idx) {
+ return columns[idx].bVisible;
+ });
}
- /* Deal with the footer - add classes if required */
- $(thead).children('tr').children('th, td').addClass( classes.sHeaderTH );
- $(tfoot).children('tr').children('th, td').addClass( classes.sFooterTH );
+ // Make a copy of the master layout array, but with only the columns we want
+ for ( row=0 ; row=0 ; j-- )
- {
- if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
- {
- aoLocal[i].splice( j, 1 );
- }
- }
-
- /* Prep the applied array - it needs an element for each row */
- aApplied.push( [] );
- }
+ var layout = _fnHeaderLayout(settings, source);
+ var tr, n;
- for ( i=0, iLen=aoLocal.length ; i', { 'class': iStripes ? asStripeClasses[0] : '' } )
- .append( $('
', {
- 'valign': 'top',
- 'colSpan': _fnVisbleColumns( oSettings ),
- 'class': oSettings.oClasses.sRowEmpty
- } ).html( sZero ) )[0];
+ anRows[ 0 ] = _emptyRow(oSettings);
}
/* Header and footer callbacks */
@@ -3590,13 +3408,14 @@
_fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
_fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
- var body = $(oSettings.nTBody);
-
body.children().detach();
body.append( $(anRows) );
+ // Empty table needs a specific class
+ $(oSettings.nTableWrapper).toggleClass('dt-empty-footer', $('tr', oSettings.nTFoot).length === 0);
+
/* Call all required callback functions for the end of a draw */
- _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
+ _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings], true );
/* Draw is complete, sorting and filtering must be as well */
oSettings.bSorted = false;
@@ -3612,188 +3431,353 @@
* the paging is reset to the first page
* @memberof DataTable#oApi
*/
- function _fnReDraw( settings, holdPosition )
+ function _fnReDraw( settings, holdPosition, recompute )
{
var
features = settings.oFeatures,
sort = features.bSort,
filter = features.bFilter;
- if ( sort ) {
- _fnSort( settings );
- }
+ if (recompute === undefined || recompute === true) {
+ if ( sort ) {
+ _fnSort( settings );
+ }
+
+ if ( filter ) {
+ _fnFilterComplete( settings, settings.oPreviousSearch );
+ }
+ else {
+ // No filtering, so we want to just use the display master
+ settings.aiDisplay = settings.aiDisplayMaster.slice();
+ }
+ }
+
+ if ( holdPosition !== true ) {
+ settings._iDisplayStart = 0;
+ }
+
+ // Let any modules know about the draw hold position state (used by
+ // scrolling internally)
+ settings._drawHold = holdPosition;
+
+ _fnDraw( settings );
+
+ settings._drawHold = false;
+ }
+
+
+ /*
+ * Table is empty - create a row with an empty message in it
+ */
+ function _emptyRow ( settings ) {
+ var oLang = settings.oLanguage;
+ var zero = oLang.sZeroRecords;
+ var dataSrc = _fnDataSource( settings );
+
+ if ( settings.iDraw <= 1 && (dataSrc === 'ajax' || dataSrc === 'ssp') )
+ {
+ zero = oLang.sLoadingRecords;
+ }
+ else if ( oLang.sEmptyTable && settings.fnRecordsTotal() === 0 )
+ {
+ zero = oLang.sEmptyTable;
+ }
+
+ return $( '
' )
+ .append( $('
', {
+ 'colSpan': _fnVisbleColumns( settings ),
+ 'class': settings.oClasses.empty.row
+ } ).html( zero ) )[0];
+ }
+
+
+ /**
+ * Convert a `layout` object given by a user to the object structure needed
+ * for the renderer. This is done twice, once for above and once for below
+ * the table. Ordering must also be considered.
+ *
+ * @param {*} settings DataTables settings object
+ * @param {*} layout Layout object to convert
+ * @param {string} side `top` or `bottom`
+ * @returns Converted array structure - one item for each row.
+ */
+ function _layoutArray ( settings, layout, side )
+ {
+ var groups = {};
+
+ // Combine into like groups (e.g. `top`, `top2`, etc)
+ $.each( layout, function ( pos, val ) {
+ if (val === null) {
+ return;
+ }
+
+ var splitPos = pos.replace(/([A-Z])/g, ' $1').split(' ');
+
+ if ( ! groups[ splitPos[0] ] ) {
+ groups[ splitPos[0] ] = {};
+ }
+
+ var align = splitPos.length === 1 ?
+ 'full' :
+ splitPos[1].toLowerCase();
+ var group = groups[ splitPos[0] ];
+
+ // Transform to an object with a contents property
+ if ( $.isPlainObject( val ) ) {
+ // Already a group from a previous pass
+ if (val.contents) {
+ group[ align ] = val;
+ }
+ else {
+ // For objects, each property becomes an entry in the contents
+ // array for this insert position
+ group[ align ] = {
+ contents: Object.keys(val).map(function (key) {
+ return {
+ feature: key,
+ opts: val[key]
+ };
+ })
+ };
+ }
+ }
+ else {
+ group[ align ] = {
+ contents: val
+ };
+ }
+
+ // And make contents an array
+ if ( ! Array.isArray( group[ align ].contents ) ) {
+ group[ align ].contents = [ group[ align ].contents ];
+ }
+ } );
+
+ var filtered = Object.keys(groups)
+ .map( function ( pos ) {
+ // Filter to only the side we need
+ if ( pos.indexOf(side) !== 0 ) {
+ return null;
+ }
+
+ return {
+ name: pos,
+ val: groups[pos]
+ };
+ } )
+ .filter( function (item) {
+ return item !== null;
+ });
+
+ // Order by item identifier
+ filtered.sort( function ( a, b ) {
+ var order1 = a.name.replace(/[^0-9]/g, '') * 1;
+ var order2 = b.name.replace(/[^0-9]/g, '') * 1;
+
+ return order2 - order1;
+ } );
+
+ if ( side === 'bottom' ) {
+ filtered.reverse();
+ }
+
+ // Split into rows
+ var rows = [];
+ for ( var i=0, ien=filtered.length ; i')
+ .attr({
+ id: settings.sTableId+'_wrapper',
+ 'class': classes.container
+ })
+ .insertBefore(table);
- if ( filter ) {
- _fnFilterComplete( settings, settings.oPreviousSearch );
- }
- else {
- // No filtering, so we want to just use the display master
- settings.aiDisplay = settings.aiDisplayMaster.slice();
- }
+ settings.nTableWrapper = insert[0];
- if ( holdPosition !== true ) {
- settings._iDisplayStart = 0;
+ var top = _layoutArray( settings, settings.layout, 'top' );
+ var bottom = _layoutArray( settings, settings.layout, 'bottom' );
+ var renderer = _fnRenderer( settings, 'layout' );
+
+ if (settings.sDom) {
+ // Legacy
+ _fnLayoutDom(settings, settings.sDom, insert);
}
+ else {
+ // Everything above - the renderer will actually insert the contents into the document
+ top.forEach(function (item) {
+ renderer( settings, insert, item );
+ });
- // Let any modules know about the draw hold position state (used by
- // scrolling internally)
- settings._drawHold = holdPosition;
+ // The table - always the center of attention
+ renderer( settings, insert, {
+ full: {
+ table: true,
+ contents: [ _fnFeatureHtmlTable(settings) ]
+ }
+ } );
- _fnDraw( settings );
+ // Everything below
+ bottom.forEach(function (item) {
+ renderer( settings, insert, item );
+ });
+ }
- settings._drawHold = false;
+ // Processing floats on top, so it isn't an inserted feature
+ _processingHtml( settings );
}
-
/**
- * Add the options to the page HTML for the table
- * @param {object} oSettings dataTables settings object
- * @memberof DataTable#oApi
+ * Draw the table with the legacy DOM property
+ * @param {*} settings DT settings object
+ * @param {*} dom DOM string
+ * @param {*} insert Insert point
*/
- function _fnAddOptionsHtml ( oSettings )
+ function _fnLayoutDom( settings, dom, insert )
{
- var classes = oSettings.oClasses;
- var table = $(oSettings.nTable);
- var holding = $('').insertBefore( table ); // Holding element for speed
- var features = oSettings.oFeatures;
-
- // All DataTables are wrapped in a div
- var insert = $('', {
- id: oSettings.sTableId+'_wrapper',
- 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
- } );
-
- oSettings.nHolding = holding[0];
- oSettings.nTableWrapper = insert[0];
- oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
+ var parts = dom.match(/(".*?")|('.*?')|./g);
+ var featureNode, option, newNode, next, attr;
- /* Loop over the user set positioning and place the elements as needed */
- var aDom = oSettings.sDom.split('');
- var featureNode, cOption, nNewNode, cNext, sAttr, j;
- for ( var i=0 ; i')[0];
+ if ( option == '<' ) {
+ // New container div
+ newNode = $('');
- /* Check to see if we should append an id and/or a class name to the container */
- cNext = aDom[i+1];
- if ( cNext == "'" || cNext == '"' )
- {
- sAttr = "";
- j = 2;
- while ( aDom[i+j] != cNext )
- {
- sAttr += aDom[i+j];
- j++;
- }
+ // Check to see if we should append an id and/or a class name to the container
+ next = parts[i+1];
- /* Replace jQuery UI constants @todo depreciated */
- if ( sAttr == "H" )
- {
- sAttr = classes.sJUIHeader;
- }
- else if ( sAttr == "F" )
- {
- sAttr = classes.sJUIFooter;
- }
+ if ( next[0] == "'" || next[0] == '"' ) {
+ attr = next.replace(/['"]/g, '');
+
+ var id = '', className;
/* The attribute can be in the format of "#id.class", "#id" or "class" This logic
* breaks the string into parts and applies them as needed
*/
- if ( sAttr.indexOf('.') != -1 )
- {
- var aSplit = sAttr.split('.');
- nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
- nNewNode.className = aSplit[1];
+ if ( attr.indexOf('.') != -1 ) {
+ var split = attr.split('.');
+
+ id = split[0];
+ className = split[1];
}
- else if ( sAttr.charAt(0) == "#" )
- {
- nNewNode.id = sAttr.substr(1, sAttr.length-1);
+ else if ( attr[0] == "#" ) {
+ id = attr;
}
- else
- {
- nNewNode.className = sAttr;
+ else {
+ className = attr;
}
- i += j; /* Move along the position array */
+ newNode
+ .attr('id', id.substring(1))
+ .addClass(className);
+
+ i++; // Move along the position array
}
- insert.append( nNewNode );
- insert = $(nNewNode);
+ insert.append( newNode );
+ insert = newNode;
}
- else if ( cOption == '>' )
- {
- /* End container div */
+ else if ( option == '>' ) {
+ // End container div
insert = insert.parent();
}
- // @todo Move options into their own plugins?
- else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
- {
- /* Length */
- featureNode = _fnFeatureHtmlLength( oSettings );
- }
- else if ( cOption == 'f' && features.bFilter )
- {
- /* Filter */
- featureNode = _fnFeatureHtmlFilter( oSettings );
- }
- else if ( cOption == 'r' && features.bProcessing )
- {
- /* pRocessing */
- featureNode = _fnFeatureHtmlProcessing( oSettings );
- }
- else if ( cOption == 't' )
- {
- /* Table */
- featureNode = _fnFeatureHtmlTable( oSettings );
- }
- else if ( cOption == 'i' && features.bInfo )
- {
- /* Info */
- featureNode = _fnFeatureHtmlInfo( oSettings );
- }
- else if ( cOption == 'p' && features.bPaginate )
- {
- /* Pagination */
- featureNode = _fnFeatureHtmlPaginate( oSettings );
+ else if ( option == 't' ) {
+ // Table
+ featureNode = _fnFeatureHtmlTable( settings );
}
- else if ( DataTable.ext.feature.length !== 0 )
+ else
{
- /* Plug-in features */
- var aoFeatures = DataTable.ext.feature;
- for ( var k=0, kLen=aoFeatures.length ; k/g, "" );
+ columnDef.autoTitle = true;
+ }
+ }
+ else {
+ // Footer specific operations
+ if (columnDef.footer) {
+ cell.innerHTML = columnDef.footer;
+ }
+ }
+
+ // Fall back to the aria-label attribute on the table header if no ariaTitle is
+ // provided.
+ if (! columnDef.ariaTitle) {
+ columnDef.ariaTitle = $(cell).attr("aria-label") || columnDef.sTitle;
+ }
+
+ // Column specific class names
+ if ( columnDef.className ) {
+ $(cell).addClass( columnDef.className );
+ }
+ }
+
+ // Wrap the column title so we can write to it in future
+ if ( $('span.dt-column-title', cell).length === 0) {
+ $('')
+ .addClass('dt-column-title')
+ .append(cell.childNodes)
+ .appendTo(cell);
+ }
+
+ if ( isHeader && $('span.dt-column-order', cell).length === 0) {
+ $('')
+ .addClass('dt-column-order')
+ .appendTo(cell);
}
}
- }
- nCell = nCell.nextSibling;
- }
- }
- }
+ // If there is col / rowspan, copy the information into the layout grid
+ for ( l=0 ; l';
-
- var str = language.sSearch;
- str = str.match(/_INPUT_/) ?
- str.replace('_INPUT_', input) :
- str+input;
-
- var filter = $('', {
- 'id': ! features.f ? tableId+'_filter' : null,
- 'class': classes.sFilter
- } )
- .append( $('' ).append( str ) );
-
- var searchFn = function(event) {
- /* Update all other filter input elements for the new display */
- var n = features.f;
- var val = !this.value ? "" : this.value; // mental IE8 fix :-(
- if(previousSearch.return && event.key !== "Enter") {
- return;
- }
- /* Now do the filter */
- if ( val != previousSearch.sSearch ) {
- _fnFilterComplete( settings, {
- "sSearch": val,
- "bRegex": previousSearch.bRegex,
- "bSmart": previousSearch.bSmart ,
- "bCaseInsensitive": previousSearch.bCaseInsensitive,
- "return": previousSearch.return
- } );
-
- // Need to redraw, without resorting
- settings._iDisplayStart = 0;
- _fnDraw( settings );
- }
- };
+ function _fnAjaxDataSrcParam (settings, param, json) {
+ var dataSrc = $.isPlainObject( settings.ajax )
+ ? settings.ajax.dataSrc
+ : null;
- var searchDelay = settings.searchDelay !== null ?
- settings.searchDelay :
- _fnDataSource( settings ) === 'ssp' ?
- 400 :
- 0;
+ if (dataSrc && dataSrc[param]) {
+ // Get from custom location
+ return _fnGetObjectDataFn( dataSrc[param] )( json );
+ }
- var jqFilter = $('input', filter)
- .val( previousSearch.sSearch )
- .attr( 'placeholder', language.sSearchPlaceholder )
- .on(
- 'keyup.DT search.DT input.DT paste.DT cut.DT',
- searchDelay ?
- _fnThrottle( searchFn, searchDelay ) :
- searchFn
- )
- .on( 'mouseup.DT', function(e) {
- // Edge fix! Edge 17 does not trigger anything other than mouse events when clicking
- // on the clear icon (Edge bug 17584515). This is safe in other browsers as `searchFn`
- // checks the value to see if it has changed. In other browsers it won't have.
- setTimeout( function () {
- searchFn.call(jqFilter[0], e);
- }, 10);
- } )
- .on( 'keypress.DT', function(e) {
- /* Prevent form submission */
- if ( e.keyCode == 13 ) {
- return false;
- }
- } )
- .attr('aria-controls', tableId);
+ // else - Default behaviour
+ var old = '';
- // Update the input elements whenever the table is filtered
- $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
- if ( settings === s ) {
- // IE9 throws an 'unknown error' if document.activeElement is used
- // inside an iframe or frame...
- try {
- if ( jqFilter[0] !== document.activeElement ) {
- jqFilter.val( previousSearch.sSearch );
- }
- }
- catch ( e ) {}
- }
- } );
+ // Legacy support
+ if (param === 'draw') {
+ old = 'sEcho';
+ }
+ else if (param === 'recordsTotal') {
+ old = 'iTotalRecords';
+ }
+ else if (param === 'recordsFiltered') {
+ old = 'iTotalDisplayRecords';
+ }
- return filter[0];
+ return json[old] !== undefined
+ ? json[old]
+ : json[param];
}
/**
* Filter the table using both the global filter and column based filtering
- * @param {object} oSettings dataTables settings object
- * @param {object} oSearch search information
- * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
+ * @param {object} settings dataTables settings object
+ * @param {object} input search information
* @memberof DataTable#oApi
*/
- function _fnFilterComplete ( oSettings, oInput, iForce )
- {
- var oPrevSearch = oSettings.oPreviousSearch;
- var aoPrevSearch = oSettings.aoPreSearchCols;
- var fnSaveFilter = function ( oFilter ) {
- /* Save the filtering values */
- oPrevSearch.sSearch = oFilter.sSearch;
- oPrevSearch.bRegex = oFilter.bRegex;
- oPrevSearch.bSmart = oFilter.bSmart;
- oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
- oPrevSearch.return = oFilter.return;
- };
- var fnRegex = function ( o ) {
- // Backwards compatibility with the bEscapeRegex option
- return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
- };
+ function _fnFilterComplete ( settings, input )
+ {
+ var columnsSearch = settings.aoPreSearchCols;
// Resolve any column types that are unknown due to addition or invalidation
// @todo As per sort - can this be moved into an event handler?
- _fnColumnTypes( oSettings );
+ _fnColumnTypes( settings );
- /* In server-side processing all filtering is done by the server, so no point hanging around here */
- if ( _fnDataSource( oSettings ) != 'ssp' )
+ // In server-side processing all filtering is done by the server, so no point hanging around here
+ if ( _fnDataSource( settings ) != 'ssp' )
{
- /* Global filter */
- _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
- fnSaveFilter( oInput );
+ // Check if any of the rows were invalidated
+ _fnFilterData( settings );
+
+ // Start from the full data set
+ settings.aiDisplay = settings.aiDisplayMaster.slice();
- /* Now do the individual column filter */
- for ( var i=0 ; i input.length ||
- input.indexOf(prevSearch) !== 0 ||
- settings.bSorted // On resort, the display master needs to be
- // re-filtered since indexes will have changed
- ) {
- settings.aiDisplay = displayMaster.slice();
- }
+ // Search term can be a function, regex or string - if a string we apply our
+ // smart filtering regex (assuming the options require that)
+ var searchFunc = typeof input === 'function' ? input : null;
+ var rpSearch = input instanceof RegExp
+ ? input
+ : searchFunc
+ ? null
+ : _fnFilterCreateSearch( input, options );
- // Search the display array
- display = settings.aiDisplay;
+ // Then for each row, does the test pass. If not, lop the row from the array
+ while (i < searchRows.length) {
+ var row = settings.aoData[ searchRows[i] ];
+ var data = column === undefined
+ ? row._sFilterRow
+ : row._aFilterData[ column ];
- for ( i=0 ; i 1) {
+ not.push('(?!'+word+')');
+ }
+
+ word = '';
+ }
+
return word.replace('"', '');
} );
- search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
+ var match = not.length
+ ? not.join('')
+ : '';
+
+ var boundary = options.boundary
+ ? '\\b'
+ : '';
+
+ search = '^(?=.*?'+boundary+a.join( ')(?=.*?'+boundary )+')('+match+'.)*$';
}
- return new RegExp( search, caseInsensitive ? 'i' : '' );
+ return new RegExp( search, options.caseInsensitive ? 'i' : '' );
}
@@ -4629,12 +4511,17 @@
function _fnFilterData ( settings )
{
var columns = settings.aoColumns;
+ var data = settings.aoData;
var column;
- var i, j, ien, jen, filterData, cellData, row;
+ var j, jen, filterData, cellData, row;
var wasInvalidated = false;
- for ( i=0, ien=settings.aoData.length ; i', {
- 'class': settings.oClasses.sInfo,
- 'id': ! nodes ? tid+'_info' : null
- } );
-
- if ( ! nodes ) {
- // Update display on each draw
- settings.aoDrawCallback.push( {
- "fn": _fnUpdateInfo,
- "sName": "information"
- } );
-
- n
- .attr( 'role', 'status' )
- .attr( 'aria-live', 'polite' );
-
- // Table is described by our info div
- $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
- }
-
- return n[0];
- }
-
-
- /**
- * Update the information elements in the display
- * @param {object} settings dataTables settings object
- * @memberof DataTable#oApi
- */
- function _fnUpdateInfo ( settings )
- {
- /* Show information about the table */
- var nodes = settings.aanFeatures.i;
- if ( nodes.length === 0 ) {
- return;
- }
-
- var
- lang = settings.oLanguage,
- start = settings._iDisplayStart+1,
- end = settings.fnDisplayEnd(),
- max = settings.fnRecordsTotal(),
- total = settings.fnRecordsDisplay(),
- out = total ?
- lang.sInfo :
- lang.sInfoEmpty;
-
- if ( total !== max ) {
- /* Record set after filtering */
- out += ' ' + lang.sInfoFiltered;
- }
-
- // Convert the macros
- out += lang.sInfoPostFix;
- out = _fnInfoMacros( settings, out );
-
- var callback = lang.fnInfoCallback;
- if ( callback !== null ) {
- out = callback.call( settings.oInstance,
- settings, start, end, max, total, out
- );
- }
-
- $(nodes).html( out );
- }
-
-
- function _fnInfoMacros ( settings, str )
- {
- // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
- // internally
- var
- formatter = settings.fnFormatNumber,
- start = settings._iDisplayStart+1,
- len = settings._iDisplayLength,
- vis = settings.fnRecordsDisplay(),
- all = len === -1;
-
- return str.
- replace(/_START_/g, formatter.call( settings, start ) ).
- replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
- replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
- replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
- replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
- replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
- }
-
-
-
/**
* Draw the table for the first time, adding all required features
* @param {object} settings dataTables settings object
@@ -4830,10 +4580,7 @@
*/
function _fnInitialise ( settings )
{
- var i, iLen, iAjaxStart=settings.iInitDisplayStart;
- var columns = settings.aoColumns, column;
- var features = settings.oFeatures;
- var deferLoading = settings.bDeferLoading; // value modified by the draw
+ var i, iAjaxStart=settings.iInitDisplayStart;
/* Ensure that the table data is fully initialised */
if ( ! settings.bInitialised ) {
@@ -4841,31 +4588,22 @@
return;
}
- /* Show the display HTML options */
- _fnAddOptionsHtml( settings );
-
/* Build and draw the header / footer for the table */
- _fnBuildHead( settings );
+ _fnBuildHead( settings, 'header' );
+ _fnBuildHead( settings, 'footer' );
_fnDrawHead( settings, settings.aoHeader );
_fnDrawHead( settings, settings.aoFooter );
- /* Okay to show that something is going on now */
- _fnProcessingDisplay( settings, true );
-
- /* Calculate sizes for columns */
- if ( features.bAutoWidth ) {
- _fnCalculateColumnWidths( settings );
- }
+ // Enable features
+ _fnAddOptionsHtml( settings );
+ _fnSortInit( settings );
- for ( i=0, iLen=columns.length ; i', {
- 'name': tableId+'_length',
- 'aria-controls': tableId,
- 'class': classes.sLengthSelect
- } );
-
- for ( var i=0, ien=lengths.length ; i').addClass( classes.sLength );
- if ( ! settings.aanFeatures.l ) {
- div[0].id = tableId+'_length';
- }
-
- div.children().append(
- settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
- );
-
- // Can't use `select` variable as user might provide their own and the
- // reference is broken by the use of outerHTML
- $('select', div)
- .val( settings._iDisplayLength )
- .on( 'change.DT', function(e) {
- _fnLengthChange( settings, $(this).val() );
- _fnDraw( settings );
- } );
-
- // Update node value whenever anything changes the table's length
- $(settings.nTable).on( 'length.dt.DT', function (e, s, len) {
- if ( settings === s ) {
- $('select', div).val( len );
- }
- } );
-
- return div[0];
- }
-
-
-
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Note that most of the paging logic is done in
- * DataTable.ext.pager
- */
-
- /**
- * Generate the node required for default pagination
- * @param {object} oSettings dataTables settings object
- * @returns {node} Pagination feature node
- * @memberof DataTable#oApi
- */
- function _fnFeatureHtmlPaginate ( settings )
- {
- var
- type = settings.sPaginationType,
- plugin = DataTable.ext.pager[ type ],
- modern = typeof plugin === 'function',
- redraw = function( settings ) {
- _fnDraw( settings );
- },
- node = $('').addClass( settings.oClasses.sPaging + type )[0],
- features = settings.aanFeatures;
-
- if ( ! modern ) {
- plugin.fnInit( settings, node, redraw );
- }
-
- /* Add a draw callback for the pagination on first instance, to update the paging display */
- if ( ! features.p )
- {
- node.id = settings.sTableId+'_paginate';
-
- settings.aoDrawCallback.push( {
- "fn": function( settings ) {
- if ( modern ) {
- var
- start = settings._iDisplayStart,
- len = settings._iDisplayLength,
- visRecords = settings.fnRecordsDisplay(),
- all = len === -1,
- page = all ? 0 : Math.ceil( start / len ),
- pages = all ? 1 : Math.ceil( visRecords / len ),
- buttons = plugin(page, pages),
- i, ien;
-
- for ( i=0, ien=features.p.length ; i', {
- 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
- 'class': settings.oClasses.sProcessing,
- 'role': 'status'
- } )
- .html( settings.oLanguage.sProcessing )
- .append('
')
+ .insertBefore( table );
+
+ $(table).on( 'processing.dt.DT', function (e, s, show) {
+ n.css( 'display', show ? 'block' : 'none' );
+ } );
+ }
}
/**
* Display or hide the processing indicator
- * @param {object} settings dataTables settings object
+ * @param {object} settings DataTables settings object
* @param {bool} show Show the processing indicator (true) or not (false)
- * @memberof DataTable#oApi
*/
function _fnProcessingDisplay ( settings, show )
{
- if ( settings.oFeatures.bProcessing ) {
- $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
- }
-
_fnCallbackFire( settings, null, 'processing', [settings, show] );
}
-
/**
* Add any control elements for the table - specifically scrolling
* @param {object} settings dataTables settings object
@@ -5196,9 +4807,9 @@
var scrollX = scroll.sX;
var scrollY = scroll.sY;
- var classes = settings.oClasses;
- var caption = table.children('caption');
- var captionSide = caption.length ? caption[0]._captionSide : null;
+ var classes = settings.oClasses.scrolling;
+ var caption = settings.captionNode;
+ var captionSide = caption ? caption._captionSide : null;
var headerClone = $( table[0].cloneNode(false) );
var footerClone = $( table[0].cloneNode(false) );
var footer = table.children('tfoot');
@@ -5227,9 +4838,9 @@
* table - scroll foot table
* tfoot - tfoot
*/
- var scroller = $( _div, { 'class': classes.sScrollWrapper } )
+ var scroller = $( _div, { 'class': classes.container } )
.append(
- $(_div, { 'class': classes.sScrollHead } )
+ $(_div, { 'class': classes.header.self } )
.css( {
overflow: 'hidden',
position: 'relative',
@@ -5237,7 +4848,7 @@
width: scrollX ? size(scrollX) : '100%'
} )
.append(
- $(_div, { 'class': classes.sScrollHeadInner } )
+ $(_div, { 'class': classes.header.inner } )
.css( {
'box-sizing': 'content-box',
width: scroll.sXInner || '100%'
@@ -5254,7 +4865,7 @@
)
)
.append(
- $(_div, { 'class': classes.sScrollBody } )
+ $(_div, { 'class': classes.body } )
.css( {
position: 'relative',
overflow: 'auto',
@@ -5265,14 +4876,14 @@
if ( footer ) {
scroller.append(
- $(_div, { 'class': classes.sScrollFoot } )
+ $(_div, { 'class': classes.footer.self } )
.css( {
overflow: 'hidden',
border: 0,
width: scrollX ? size(scrollX) : '100%'
} )
.append(
- $(_div, { 'class': classes.sScrollFootInner } )
+ $(_div, { 'class': classes.footer.inner } )
.append(
footerClone
.removeAttr('id')
@@ -5292,17 +4903,26 @@
var scrollFoot = footer ? children[2] : null;
// When the body is scrolled, then we also want to scroll the headers
- if ( scrollX ) {
- $(scrollBody).on( 'scroll.DT', function (e) {
- var scrollLeft = this.scrollLeft;
+ $(scrollBody).on( 'scroll.DT', function () {
+ var scrollLeft = this.scrollLeft;
- scrollHead.scrollLeft = scrollLeft;
+ scrollHead.scrollLeft = scrollLeft;
- if ( footer ) {
- scrollFoot.scrollLeft = scrollLeft;
- }
- } );
- }
+ if ( footer ) {
+ scrollFoot.scrollLeft = scrollLeft;
+ }
+ } );
+
+ // When focus is put on the header cells, we might need to scroll the body
+ $('th, td', scrollHead).on('focus', function () {
+ var scrollLeft = scrollHead.scrollLeft;
+
+ scrollBody.scrollLeft = scrollLeft;
+
+ if ( footer ) {
+ scrollBody.scrollLeft = scrollLeft;
+ }
+ });
$(scrollBody).css('max-height', scrollY);
if (! scroll.bCollapse) {
@@ -5314,10 +4934,7 @@
settings.nScrollFoot = scrollFoot;
// On redraw - align columns
- settings.aoDrawCallback.push( {
- "fn": _fnScrollDraw,
- "sName": "scrolling"
- } );
+ settings.aoDrawCallback.push(_fnScrollDraw);
return scroller[0];
}
@@ -5331,8 +4948,8 @@
* Welcome to the most horrible function DataTables. The process that this
* function follows is basically:
* 1. Re-create the table inside the scrolling div
- * 2. Take live measurements from the DOM
- * 3. Apply the measurements to align the columns
+ * 2. Correct colgroup > col values if needed
+ * 3. Copy colgroup > col over to header and footer
* 4. Clean up
*
* @param {object} settings dataTables settings object
@@ -5344,43 +4961,20 @@
// to try and keep the minimised size as small as possible
var
scroll = settings.oScroll,
- scrollX = scroll.sX,
- scrollXInner = scroll.sXInner,
- scrollY = scroll.sY,
barWidth = scroll.iBarWidth,
divHeader = $(settings.nScrollHead),
- divHeaderStyle = divHeader[0].style,
divHeaderInner = divHeader.children('div'),
- divHeaderInnerStyle = divHeaderInner[0].style,
divHeaderTable = divHeaderInner.children('table'),
divBodyEl = settings.nScrollBody,
divBody = $(divBodyEl),
- divBodyStyle = divBodyEl.style,
divFooter = $(settings.nScrollFoot),
divFooterInner = divFooter.children('div'),
divFooterTable = divFooterInner.children('table'),
header = $(settings.nTHead),
table = $(settings.nTable),
- tableEl = table[0],
- tableStyle = tableEl.style,
- footer = settings.nTFoot ? $(settings.nTFoot) : null,
+ footer = settings.nTFoot && $('th, td', settings.nTFoot).length ? $(settings.nTFoot) : null,
browser = settings.oBrowser,
- ie67 = browser.bScrollOversize,
- dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
- headerTrgEls, footerTrgEls,
- headerSrcEls, footerSrcEls,
- headerCopy, footerCopy,
- headerWidths=[], footerWidths=[],
- headerContent=[], footerContent=[],
- idx, correction, sanityWidth,
- zeroOut = function(nSizer) {
- var style = nSizer.style;
- style.paddingTop = "0";
- style.paddingBottom = "0";
- style.borderTopWidth = "0";
- style.borderBottomWidth = "0";
- style.height = 0;
- };
+ headerCopy, footerCopy;
// If the scrollbar visibility has changed from the last draw, we need to
// adjust the column sizes as the table width will have changed to account
@@ -5396,214 +4990,95 @@
settings.scrollBarVis = scrollBarVis;
}
- /*
- * 1. Re-create the table inside the scrolling div
- */
-
+ // 1. Re-create the table inside the scrolling div
// Remove the old minimised thead and tfoot elements in the inner table
table.children('thead, tfoot').remove();
- if ( footer ) {
- footerCopy = footer.clone().prependTo( table );
- footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
- footerSrcEls = footerCopy.find('tr');
- footerCopy.find('[id]').removeAttr('id');
- }
-
// Clone the current header and footer elements and then place it into the inner table
headerCopy = header.clone().prependTo( table );
- headerTrgEls = header.find('tr'); // original header is in its own table
- headerSrcEls = headerCopy.find('tr');
headerCopy.find('th, td').removeAttr('tabindex');
headerCopy.find('[id]').removeAttr('id');
-
- /*
- * 2. Take live measurements from the DOM - do not alter the DOM itself!
- */
-
- // Remove old sizing and apply the calculated column widths
- // Get the unique column headers in the newly created (cloned) header. We want to apply the
- // calculated sizes to this header
- if ( ! scrollX )
- {
- divBodyStyle.width = '100%';
- divHeader[0].style.width = '100%';
- }
-
- $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
- idx = _fnVisibleToColumnIndex( settings, i );
- el.style.width = settings.aoColumns[idx].sWidth;
- } );
-
if ( footer ) {
- _fnApplyToChildren( function(n) {
- n.style.width = "";
- }, footerSrcEls );
- }
-
- // Size the table as a whole
- sanityWidth = table.outerWidth();
- if ( scrollX === "" ) {
- // No x scrolling
- tableStyle.width = "100%";
-
- // IE7 will make the width of the table when 100% include the scrollbar
- // - which is shouldn't. When there is a scrollbar we need to take this
- // into account.
- if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
- divBody.css('overflow-y') == "scroll")
- ) {
- tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
- }
-
- // Recalculate the sanity width
- sanityWidth = table.outerWidth();
- }
- else if ( scrollXInner !== "" ) {
- // legacy x scroll inner has been given - use it
- tableStyle.width = _fnStringToCss(scrollXInner);
-
- // Recalculate the sanity width
- sanityWidth = table.outerWidth();
+ footerCopy = footer.clone().prependTo( table );
+ footerCopy.find('[id]').removeAttr('id');
}
- // Hidden header should have zero height, so remove padding and borders. Then
- // set the width based on the real headers
-
- // Apply all styles in one pass
- _fnApplyToChildren( zeroOut, headerSrcEls );
-
- // Read all widths in next pass
- _fnApplyToChildren( function(nSizer) {
- var style = window.getComputedStyle ?
- window.getComputedStyle(nSizer).width :
- _fnStringToCss( $(nSizer).width() );
-
- headerContent.push( nSizer.innerHTML );
- headerWidths.push( style );
- }, headerSrcEls );
+ // 2. Correct colgroup > col values if needed
+ // It is possible that the cell sizes are smaller than the content, so we need to
+ // correct colgroup>col for such cases. This can happen if the auto width detection
+ // uses a cell which has a longer string, but isn't the widest! For example
+ // "Chief Executive Officer (CEO)" is the longest string in the demo, but
+ // "Systems Administrator" is actually the widest string since it doesn't collapse.
+ if (settings.aiDisplay.length) {
+ // Get the column sizes from the first row in the table
+ var colSizes = table.find('tbody tr').eq(0).find('th, td').map(function () {
+ return $(this).outerWidth();
+ });
- // Apply all widths in final pass
- _fnApplyToChildren( function(nToSize, i) {
- nToSize.style.width = headerWidths[i];
- }, headerTrgEls );
+ // Check against what the colgroup > col is set to and correct if needed
+ $('col', settings.colgroup).each(function (i) {
+ var colWidth = this.style.width.replace('px', '');
- $(headerSrcEls).css('height', 0);
+ if (colWidth !== colSizes[i]) {
+ this.style.width = colSizes[i] + 'px';
+ }
+ });
+ }
- /* Same again with the footer if we have one */
- if ( footer )
- {
- _fnApplyToChildren( zeroOut, footerSrcEls );
+ // 3. Copy the colgroup over to the header and footer
+ divHeaderTable
+ .find('colgroup')
+ .remove();
- _fnApplyToChildren( function(nSizer) {
- footerContent.push( nSizer.innerHTML );
- footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
- }, footerSrcEls );
+ divHeaderTable.append(settings.colgroup.clone());
- _fnApplyToChildren( function(nToSize, i) {
- nToSize.style.width = footerWidths[i];
- }, footerTrgEls );
+ if ( footer ) {
+ divFooterTable
+ .find('colgroup')
+ .remove();
- $(footerSrcEls).height(0);
+ divFooterTable.append(settings.colgroup.clone());
}
-
- /*
- * 3. Apply the measurements
- */
-
// "Hide" the header and footer that we used for the sizing. We need to keep
// the content of the cell so that the width applied to the header and body
- // both match, but we want to hide it completely. We want to also fix their
- // width to what they currently are
- _fnApplyToChildren( function(nSizer, i) {
- nSizer.innerHTML = '
';
- nSizer.childNodes[0].style.height = "0";
- nSizer.childNodes[0].style.overflow = "hidden";
- nSizer.style.width = footerWidths[i];
- }, footerSrcEls );
- }
-
- // Sanity check that the table is of a sensible width. If not then we are going to get
- // misalignment - try to prevent this by not allowing the table to shrink below its min width
- if ( Math.round(table.outerWidth()) < Math.round(sanityWidth) )
- {
- // The min width depends upon if we have a vertical scrollbar visible or not */
- correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
- divBody.css('overflow-y') == "scroll")) ?
- sanityWidth+barWidth :
- sanityWidth;
-
- // IE6/7 are a law unto themselves...
- if ( ie67 && (divBodyEl.scrollHeight >
- divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
- ) {
- tableStyle.width = _fnStringToCss( correction-barWidth );
- }
-
- // And give the user a warning that we've stopped the table getting too small
- if ( scrollX === "" || scrollXInner !== "" ) {
- _fnLog( settings, 1, 'Possible column misalignment', 6 );
- }
- }
- else
- {
- correction = '100%';
- }
-
- // Apply to the container elements
- divBodyStyle.width = _fnStringToCss( correction );
- divHeaderStyle.width = _fnStringToCss( correction );
+ // both match, but we want to hide it completely.
+ $('th, td', headerCopy).each(function () {
+ $(this).children().wrapAll('
');
+ });
if ( footer ) {
- settings.nScrollFoot.style.width = _fnStringToCss( correction );
- }
-
-
- /*
- * 4. Clean up
- */
- if ( ! scrollY ) {
- /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
- * the scrollbar height from the visible display, rather than adding it on. We need to
- * set the height in order to sort this. Don't want to do it in any other browsers.
- */
- if ( ie67 ) {
- divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
- }
+ $('th, td', footerCopy).each(function () {
+ $(this).children().wrapAll('
');
+ });
}
- /* Finally set the width's of the header and footer tables */
- var iOuterWidth = table.outerWidth();
- divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
- divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
-
+ // 4. Clean up
// Figure out if there are scrollbar present - if so then we need a the header and footer to
// provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
- var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
- var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
- divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
+ var isScrolling = Math.floor(table.height()) > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
+ var paddingSide = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
+
+ // Set the width's of the header and footer tables
+ var outerWidth = table.outerWidth();
+
+ divHeaderTable.css('width', _fnStringToCss( outerWidth ));
+ divHeaderInner
+ .css('width', _fnStringToCss( outerWidth ))
+ .css(paddingSide, isScrolling ? barWidth+"px" : "0px");
if ( footer ) {
- divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
- divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
- divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
+ divFooterTable.css('width', _fnStringToCss( outerWidth ));
+ divFooterInner
+ .css('width', _fnStringToCss( outerWidth ))
+ .css(paddingSide, isScrolling ? barWidth+"px" : "0px");
}
// Correct DOM ordering for colgroup - comes before the thead
- table.children('colgroup').insertBefore( table.children('thead') );
+ table.children('colgroup').prependTo(table);
- /* Adjust the position of the header in case we loose the y-scrollbar */
+ // Adjust the position of the header in case we loose the y-scrollbar
divBody.trigger('scroll');
// If sorting or filtering has occurred, jump the scrolling back to the top
@@ -5613,148 +5088,81 @@
}
}
-
-
/**
- * Apply a given function to the display child nodes of an element array (typically
- * TD children of TR rows
- * @param {function} fn Method to apply to the objects
- * @param array {nodes} an1 List of elements to look through for display children
- * @param array {nodes} an2 Another list (identical structure to the first) - optional
+ * Calculate the width of columns for the table
+ * @param {object} settings dataTables settings object
* @memberof DataTable#oApi
*/
- function _fnApplyToChildren( fn, an1, an2 )
+ function _fnCalculateColumnWidths ( settings )
{
- var index=0, i=0, iLen=an1.length;
- var nNode1, nNode2;
-
- while ( i < iLen ) {
- nNode1 = an1[i].firstChild;
- nNode2 = an2 ? an2[i].firstChild : null;
-
- while ( nNode1 ) {
- if ( nNode1.nodeType === 1 ) {
- if ( an2 ) {
- fn( nNode1, nNode2, index );
- }
- else {
- fn( nNode1, index );
- }
-
- index++;
- }
-
- nNode1 = nNode1.nextSibling;
- nNode2 = an2 ? nNode2.nextSibling : null;
- }
-
- i++;
+ // Not interested in doing column width calculation if auto-width is disabled
+ if (! settings.oFeatures.bAutoWidth) {
+ return;
}
- }
-
-
- var __re_html_remove = /<.*?>/g;
-
-
- /**
- * Calculate the width of columns for the table
- * @param {object} oSettings dataTables settings object
- * @memberof DataTable#oApi
- */
- function _fnCalculateColumnWidths ( oSettings )
- {
var
- table = oSettings.nTable,
- columns = oSettings.aoColumns,
- scroll = oSettings.oScroll,
+ table = settings.nTable,
+ columns = settings.aoColumns,
+ scroll = settings.oScroll,
scrollY = scroll.sY,
scrollX = scroll.sX,
scrollXInner = scroll.sXInner,
- columnCount = columns.length,
- visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
- headerCells = $('th', oSettings.nTHead),
+ visibleColumns = _fnGetColumns( settings, 'bVisible' ),
tableWidthAttr = table.getAttribute('width'), // from DOM element
tableContainer = table.parentNode,
- userInputs = false,
- i, column, columnIdx, width, outerWidth,
- browser = oSettings.oBrowser,
- ie67 = browser.bScrollOversize;
+ i, column, columnIdx;
var styleWidth = table.style.width;
if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
tableWidthAttr = styleWidth;
}
- /* Convert any user input sizes into pixel sizes */
- for ( i=0 ; i')
+ var tr = $('
').appendTo( tmpTable.find('tbody') );
- /* If the number of columns in the DOM equals the number that we have to
- * process in DataTables, then we can use the offsets that are created by
- * the web- browser. No custom sizes can be set in order for this to happen,
- * nor scrolling used
- */
- if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
- columnCount == _fnVisbleColumns( oSettings ) &&
- columnCount == headerCells.length
- ) {
- for ( i=0 ; i').appendTo( tmpTable.find('tbody') );
-
- // Clone the table header and footer - we can't use the header / footer
- // from the cloned table, since if scrolling is active, the table's
- // real header and footer are contained in different table tags
- tmpTable.find('thead, tfoot').remove();
- tmpTable
- .append( $(oSettings.nTHead).clone() )
- .append( $(oSettings.nTFoot).clone() );
-
- // Remove any assigned widths from the footer (from scrolling)
- tmpTable.find('tfoot th, tfoot td').css('width', '');
-
- // Apply custom sizing to the cloned header
- headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
-
- for ( i=0 ; i').css( {
- width: column.sWidthOrig,
+ if ( scrollX ) {
+ $( this ).append( $('').css( {
+ width: width,
margin: 0,
padding: 0,
border: 0,
@@ -5762,96 +5170,96 @@
} ) );
}
}
-
- // Find the widest cell for each column and put it into the table
- if ( oSettings.aoData.length ) {
- for ( i=0 ; i').css( scrollX || scrollY ?
- {
- position: 'absolute',
- top: 0,
- left: 0,
- height: 1,
- right: 0,
- overflow: 'hidden'
- } :
- {}
- )
- .append( tmpTable )
- .appendTo( tableContainer );
-
- // When scrolling (X or Y) we want to set the width of the table as
- // appropriate. However, when not scrolling leave the table width as it
- // is. This results in slightly different, but I think correct behaviour
- if ( scrollX && scrollXInner ) {
- tmpTable.width( scrollXInner );
+ else {
+ this.style.width = '';
}
- else if ( scrollX ) {
- tmpTable.css( 'width', 'auto' );
- tmpTable.removeAttr('width');
+ } );
- // If there is no width attribute or style, then allow the table to
- // collapse
- if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
- tmpTable.width( tableContainer.clientWidth );
- }
- }
- else if ( scrollY ) {
+ // Find the widest piece of data for each column and put it into the table
+ for ( i=0 ; i')
+ .addClass(autoClass)
+ .addClass(column.sClass)
+ .append(insert)
+ .appendTo(tr);
+ }
+
+ // Tidy the temporary table - remove name attributes so there aren't
+ // duplicated in the dom (radio elements for example)
+ $('[name]', tmpTable).removeAttr('name');
+
+ // Table has been built, attach to the document so we can work with it.
+ // A holding element is used, positioned at the top of the container
+ // with minimal height, so it has no effect on if the container scrolls
+ // or not. Otherwise it might trigger scrolling when it actually isn't
+ // needed
+ var holder = $('').css( scrollX || scrollY ?
+ {
+ position: 'absolute',
+ top: 0,
+ left: 0,
+ height: 1,
+ right: 0,
+ overflow: 'hidden'
+ } :
+ {}
+ )
+ .append( tmpTable )
+ .appendTo( tableContainer );
+
+ // When scrolling (X or Y) we want to set the width of the table as
+ // appropriate. However, when not scrolling leave the table width as it
+ // is. This results in slightly different, but I think correct behaviour
+ if ( scrollX && scrollXInner ) {
+ tmpTable.width( scrollXInner );
+ }
+ else if ( scrollX ) {
+ tmpTable.css( 'width', 'auto' );
+ tmpTable.removeAttr('width');
+
+ // If there is no width attribute or style, then allow the table to
+ // collapse
+ if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
tmpTable.width( tableContainer.clientWidth );
}
- else if ( tableWidthAttr ) {
- tmpTable.width( tableWidthAttr );
- }
+ }
+ else if ( scrollY ) {
+ tmpTable.width( tableContainer.clientWidth );
+ }
+ else if ( tableWidthAttr ) {
+ tmpTable.width( tableWidthAttr );
+ }
- // Get the width of each column in the constructed table - we need to
- // know the inner width (so it can be assigned to the other table's
- // cells) and the outer width so we can calculate the full width of the
- // table. This is safe since DataTables requires a unique cell for each
- // column, but if ever a header can span multiple columns, this will
- // need to be modified.
- var total = 0;
- for ( i=0 ; i')
- .css( 'width', _fnStringToCss( width ) )
- .appendTo( parent || document.body );
+ bindResize();
- var val = n[0].offsetWidth;
- n.remove();
-
- return val;
- }
-
-
- /**
- * Get the widest node
- * @param {object} settings dataTables settings object
- * @param {int} colIdx column of interest
- * @returns {node} widest table node
- * @memberof DataTable#oApi
- */
- function _fnGetWidestNode( settings, colIdx )
- {
- var idx = _fnGetMaxLenString( settings, colIdx );
- if ( idx < 0 ) {
- return null;
+ settings._reszEvt = true;
}
-
- var data = settings.aoData[ idx ];
- return ! data.nTr ? // Might not have been created when deferred rendering
- $('
').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
- data.anCells[ colIdx ];
}
@@ -5942,25 +5289,45 @@
* Get the maximum strlen for each data column
* @param {object} settings dataTables settings object
* @param {int} colIdx column of interest
- * @returns {string} max string length for each column
+ * @returns {string} string of the max length
* @memberof DataTable#oApi
*/
function _fnGetMaxLenString( settings, colIdx )
{
- var s, max=-1, maxIdx = -1;
+ var column = settings.aoColumns[colIdx];
- for ( var i=0, ien=settings.aoData.length ; i max ) {
- max = s.length;
- maxIdx = i;
+ if (! column.maxLenString) {
+ var s, max='', maxLen = -1;
+
+ for ( var i=0, ien=settings.aiDisplayMaster.length ; i maxLen ) {
+ // We want the HTML in the string, but the length that
+ // is important is the stripped string
+ max = cellString;
+ maxLen = s.length;
+ }
}
+
+ column.maxLenString = max;
}
- return maxIdx;
+ return column.maxLenString;
}
@@ -5981,75 +5348,205 @@
'0px' :
s+'px';
}
-
- // Check it has a unit character already
- return s.match(/\d$/) ?
- s+'px' :
- s;
+
+ // Check it has a unit character already
+ return s.match(/\d$/) ?
+ s+'px' :
+ s;
+ }
+
+ /**
+ * Re-insert the `col` elements for current visibility
+ *
+ * @param {*} settings DT settings
+ */
+ function _colGroup( settings ) {
+ var cols = settings.aoColumns;
+
+ settings.colgroup.empty();
+
+ for (i=0 ; i 0;
+
+ _fnSortAdd( settings, columns[i], append );
+ }
+
+ _fnSort( settings );
+ _fnSortDisplay( settings );
+ _fnReDraw( settings, false, false );
+ _fnProcessingDisplay( settings, false );
+
+ if (callback) {
+ callback();
+ }
+ }, 0);
+ }
+ } );
+ }
+
+ /**
+ * Sort the display array to match the master's order
+ * @param {*} settings
+ */
+ function _fnSortDisplay(settings) {
+ var display = settings.aiDisplay;
+ var master = settings.aiDisplayMaster;
+
+ display.sort(function(a, b){
+ return master.indexOf(a) - master.indexOf(b);
+ });
+ }
+
+
+ function _fnSortResolve (settings, nestedSort, sort) {
+ var push = function ( a ) {
+ if ($.isPlainObject(a)) {
+ if (a.idx !== undefined) {
+ // Index based ordering
+ nestedSort.push([a.idx, a.dir]);
+ }
+ else if (a.name) {
+ // Name based ordering
+ var cols = _pluck( settings.aoColumns, 'sName');
+ var idx = cols.indexOf(a.name);
+
+ if (idx !== -1) {
+ nestedSort.push([idx, a.dir]);
+ }
+ }
+ }
+ else {
+ // Plain column index and direction pair
+ nestedSort.push(a);
+ }
+ };
+
+ if ( $.isPlainObject(sort) ) {
+ // Object
+ push(sort);
+ }
+ else if ( sort.length && typeof sort[0] === 'number' ) {
+ // 1D array
+ push(sort);
+ }
+ else if ( sort.length ) {
+ // 2D array
+ for (var z=0; zy ? 1 : 0;
if ( test !== 0 ) {
- return sort.dir === 'asc' ? test : -test;
+ return test;
}
}
+ else {
+ // Otherwise, use generic sorting
+ test = xy ? 1 : 0;
- x = aiOrig[a];
- y = aiOrig[b];
- return xy ? 1 : 0;
- } );
- }
- else {
- // Depreciated - remove in 1.11 (providing a plug-in option)
- // Not all sort types have formatting methods, so we have to call their sorting
- // methods.
- displayMaster.sort( function ( a, b ) {
- var
- x, y, k, l, test, sort, fn,
- len=aSort.length,
- dataA = aoData[a]._aSortData,
- dataB = aoData[b]._aSortData;
-
- for ( k=0 ; ky ? 1 : 0;
- } );
- }
- }
-
- /* Tell the draw function that we have sorted the data */
- oSettings.bSorted = true;
- }
-
-
- function _fnSortAria ( settings )
- {
- var label;
- var nextSort;
- var columns = settings.aoColumns;
- var aSort = _fnSortFlatten( settings );
- var oAria = settings.oLanguage.oAria;
-
- // ARIA attributes - need to loop all columns, to update all (removing old
- // attributes as needed)
- for ( var i=0, iLen=columns.length ; i/g, "" );
- var th = col.nTh;
-
- // IE7 is throwing an error when setting these properties with jQuery's
- // attr() and removeAttr() methods...
- th.removeAttribute('aria-sort');
+ x = aiOrig[a];
+ y = aiOrig[b];
- /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
- if ( col.bSortable ) {
- if ( aSort.length > 0 && aSort[0].col == i ) {
- th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
- nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
- }
- else {
- nextSort = asSorting[0];
- }
+ return xy ? 1 : 0;
+ } );
+ }
+ else if ( aSort.length === 0 ) {
+ // Apply index order
+ displayMaster.sort(function (x, y) {
+ return xy ? 1 : 0;
+ });
+ }
- label = sTitle + ( nextSort === "asc" ?
- oAria.sSortAscending :
- oAria.sSortDescending
- );
- }
- else {
- label = sTitle;
- }
+ if (col === undefined) {
+ // Tell the draw function that we have sorted the data
+ oSettings.bSorted = true;
- th.setAttribute('aria-label', label);
+ _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort] );
}
+
+ return displayMaster;
}
@@ -6243,7 +5698,7 @@
* @param {function} [callback] callback function
* @memberof DataTable#oApi
*/
- function _fnSortListener ( settings, colIdx, append, callback )
+ function _fnSortAdd ( settings, colIdx, append )
{
var col = settings.aoColumns[ colIdx ];
var sorting = settings.aaSorting;
@@ -6252,7 +5707,7 @@
var next = function ( a, overflow ) {
var idx = a._idx;
if ( idx === undefined ) {
- idx = $.inArray( a[1], asSorting );
+ idx = asSorting.indexOf(a[1]);
}
return idx+1 < asSorting.length ?
@@ -6262,6 +5717,10 @@
0;
};
+ if ( ! col.bSortable ) {
+ return;
+ }
+
// Convert to 2D array if needed
if ( typeof sorting[0] === 'number' ) {
sorting = settings.aaSorting = [ sorting ];
@@ -6270,7 +5729,7 @@
// If appending the sort then we are multi-column sorting
if ( append && settings.oFeatures.bSortMulti ) {
// Are we already doing some kind of sort on this column?
- var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
+ var sortIdx = _pluck(sorting, '0').indexOf(colIdx);
if ( sortIdx !== -1 ) {
// Yes, modify the sort
@@ -6308,54 +5767,6 @@
sorting.push( [ colIdx, asSorting[0] ] );
sorting[0]._idx = 0;
}
-
- // Run the sort by calling a full redraw
- _fnReDraw( settings );
-
- // callback used for async user interaction
- if ( typeof callback == 'function' ) {
- callback( settings );
- }
- }
-
-
- /**
- * Attach a sort handler (click) to a node
- * @param {object} settings dataTables settings object
- * @param {node} attachTo node to attach the handler to
- * @param {int} colIdx column sorting index
- * @param {function} [callback] callback function
- * @memberof DataTable#oApi
- */
- function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
- {
- var col = settings.aoColumns[ colIdx ];
-
- _fnBindAction( attachTo, {}, function (e) {
- /* If the column is not sortable - don't to anything */
- if ( col.bSortable === false ) {
- return;
- }
-
- // If processing is enabled use a timeout to allow the processing
- // display to be shown - otherwise to it synchronously
- if ( settings.oFeatures.bProcessing ) {
- _fnProcessingDisplay( settings, true );
-
- setTimeout( function() {
- _fnSortListener( settings, colIdx, e.shiftKey, callback );
-
- // In server-side processing, the draw callback will remove the
- // processing display
- if ( _fnDataSource( settings ) !== 'ssp' ) {
- _fnProcessingDisplay( settings, false );
- }
- }, 0 );
- }
- else {
- _fnSortListener( settings, colIdx, e.shiftKey, callback );
- }
- } );
}
@@ -6368,7 +5779,7 @@
function _fnSortingClasses( settings )
{
var oldSort = settings.aLastSort;
- var sortClass = settings.oClasses.sSortColumn;
+ var sortClass = settings.oClasses.order.position;
var sort = _fnSortFlatten( settings );
var features = settings.oFeatures;
var i, ien, colIdx;
@@ -6398,48 +5809,54 @@
// Get the data to sort a column, be it from cache, fresh (populating the
// cache), or from a sort formatter
- function _fnSortData( settings, idx )
+ function _fnSortData( settings, colIdx )
{
// Custom sorting function - provided by the sort data type
- var column = settings.aoColumns[ idx ];
+ var column = settings.aoColumns[ colIdx ];
var customSort = DataTable.ext.order[ column.sSortDataType ];
var customData;
if ( customSort ) {
- customData = customSort.call( settings.oInstance, settings, idx,
- _fnColumnIndexToVisible( settings, idx )
+ customData = customSort.call( settings.oInstance, settings, colIdx,
+ _fnColumnIndexToVisible( settings, colIdx )
);
}
// Use / populate cache
var row, cellData;
var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
+ var data = settings.aoData;
+
+ for ( var rowIdx=0 ; rowIdx 0 && s.time < +new Date() - (duration*1000) ) {
settings._bLoadingState = false;
callback();
return;
}
- // Reject old data
- var duration = settings.iStateDuration;
- if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
+ // Allow custom and plug-in manipulation functions to alter the saved data set and
+ // cancelling of loading by returning false
+ var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
+ if ( abStateLoad.indexOf(false) !== -1 ) {
settings._bLoadingState = false;
callback();
return;
@@ -6542,6 +5959,10 @@
// Store the saved state so it might be accessed at any time
settings.oLoadedState = $.extend( true, {}, s );
+ // This is needed for ColReorder, which has to happen first to allow all
+ // the stored indexes to be usable. It is not publicly documented.
+ _fnCallbackFire( settings, null, 'stateLoadInit', [settings, s], true );
+
// Page Length
if ( s.length !== undefined ) {
// If already initialised just set the value directly so that the select element is also updated
@@ -6578,7 +5999,7 @@
// Search
if ( s.search !== undefined ) {
- $.extend( settings.oPreviousSearch, _fnSearchToHung( s.search ) );
+ $.extend( settings.oPreviousSearch, s.search );
}
// Columns
@@ -6600,7 +6021,7 @@
// Search
if ( col.search !== undefined ) {
- $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
+ $.extend( settings.aoPreSearchCols[i], col.search );
}
}
@@ -6613,26 +6034,8 @@
settings._bLoadingState = false;
_fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
callback();
- };
-
-
- /**
- * Return the settings object for a particular table
- * @param {node} table table we are using as a dataTable
- * @returns {object} Settings object - or null if not found
- * @memberof DataTable#oApi
- */
- function _fnSettingsFromNode ( table )
- {
- var settings = DataTable.settings;
- var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
-
- return idx !== -1 ?
- settings[ idx ] :
- null;
}
-
/**
* Log an error message
* @param {object} settings dataTables settings object
@@ -6648,7 +6051,7 @@
if ( tn ) {
msg += '. For more information about this error, please see '+
- 'http://datatables.net/tn/'+tn;
+ 'https://datatables.net/tn/'+tn;
}
if ( ! level ) {
@@ -6657,7 +6060,7 @@
var type = ext.sErrMode || ext.errMode;
if ( settings ) {
- _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
+ _fnCallbackFire( settings, null, 'dt-error', [ settings, tn, msg ], true );
}
if ( type == 'alert' ) {
@@ -6731,7 +6134,7 @@
var val;
for ( var prop in extender ) {
- if ( extender.hasOwnProperty(prop) ) {
+ if ( Object.prototype.hasOwnProperty.call(extender, prop) ) {
val = extender[prop];
if ( $.isPlainObject( val ) ) {
@@ -6758,47 +6161,42 @@
* This is good for accessibility since a return on the keyboard will have the
* same effect as a click, if the element has focus.
* @param {element} n Element to bind the action to
- * @param {object} oData Data object to pass to the triggered function
+ * @param {object|string} selector Selector (for delegated events) or data object
+ * to pass to the triggered function
* @param {function} fn Callback function for when the event is triggered
* @memberof DataTable#oApi
*/
- function _fnBindAction( n, oData, fn )
+ function _fnBindAction( n, selector, fn )
{
$(n)
- .on( 'click.DT', oData, function (e) {
- $(n).trigger('blur'); // Remove focus outline for mouse users
+ .on( 'click.DT', selector, function (e) {
+ fn(e);
+ } )
+ .on( 'keypress.DT', selector, function (e){
+ if ( e.which === 13 ) {
+ e.preventDefault();
fn(e);
- } )
- .on( 'keypress.DT', oData, function (e){
- if ( e.which === 13 ) {
- e.preventDefault();
- fn(e);
- }
- } )
- .on( 'selectstart.DT', function () {
- /* Take the brutal approach to cancelling text selection */
- return false;
- } );
+ }
+ } )
+ .on( 'selectstart.DT', selector, function () {
+ // Don't want a double click resulting in text selection
+ return false;
+ } );
}
/**
* Register a callback function. Easily allows a callback function to be added to
* an array store of callback functions that can then all be called together.
- * @param {object} oSettings dataTables settings object
- * @param {string} sStore Name of the array storage for the callbacks in oSettings
+ * @param {object} settings dataTables settings object
+ * @param {string} store Name of the array storage for the callbacks in oSettings
* @param {function} fn Function to be called back
- * @param {string} sName Identifying name for the callback (i.e. a label)
* @memberof DataTable#oApi
*/
- function _fnCallbackReg( oSettings, sStore, fn, sName )
+ function _fnCallbackReg( settings, store, fn )
{
- if ( fn )
- {
- oSettings[sStore].push( {
- "fn": fn,
- "sName": sName
- } );
+ if ( fn ) {
+ settings[store].push(fn);
}
}
@@ -6815,27 +6213,31 @@
* null no trigger is fired
* @param {array} args Array of arguments to pass to the callback function /
* trigger
+ * @param {boolean} [bubbles] True if the event should bubble
* @memberof DataTable#oApi
*/
- function _fnCallbackFire( settings, callbackArr, eventName, args )
+ function _fnCallbackFire( settings, callbackArr, eventName, args, bubbles )
{
var ret = [];
if ( callbackArr ) {
- ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
- return val.fn.apply( settings.oInstance, args );
+ ret = settings[callbackArr].slice().reverse().map( function (val) {
+ return val.apply( settings.oInstance, args );
} );
}
- if ( eventName !== null ) {
+ if ( eventName !== null) {
var e = $.Event( eventName+'.dt' );
var table = $(settings.nTable);
+
+ // Expose the DataTables API on the event object for easy access
+ e.dt = settings.api;
- table.trigger( e, args );
+ table[bubbles ? 'trigger' : 'triggerHandler']( e, args );
// If not yet attached to the document, trigger the event
// on the body directly to sort of simulate the bubble
- if (table.parents('body').length === 0) {
+ if (bubbles && table.parents('body').length === 0) {
$('body').trigger( e, args );
}
@@ -6905,12 +6307,43 @@
if ( settings.oFeatures.bServerSide ) {
return 'ssp';
}
- else if ( settings.ajax || settings.sAjaxSource ) {
+ else if ( settings.ajax ) {
return 'ajax';
}
return 'dom';
}
+ /**
+ * Common replacement for language strings
+ *
+ * @param {*} settings DT settings object
+ * @param {*} str String with values to replace
+ * @param {*} entries Plural number for _ENTRIES_ - can be undefined
+ * @returns String
+ */
+ function _fnMacros ( settings, str, entries )
+ {
+ // When infinite scrolling, we are always starting at 1. _iDisplayStart is
+ // used only internally
+ var
+ formatter = settings.fnFormatNumber,
+ start = settings._iDisplayStart+1,
+ len = settings._iDisplayLength,
+ vis = settings.fnRecordsDisplay(),
+ max = settings.fnRecordsTotal(),
+ all = len === -1;
+
+ return str.
+ replace(/_START_/g, formatter.call( settings, start ) ).
+ replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
+ replace(/_MAX_/g, formatter.call( settings, max ) ).
+ replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
+ replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
+ replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) ).
+ replace(/_ENTRIES_/g, settings.api.i18n('entries', '', entries) ).
+ replace(/_ENTRIES-MAX_/g, settings.api.i18n('entries', '', max) ).
+ replace(/_ENTRIES-TOTAL_/g, settings.api.i18n('entries', '', vis) );
+ }
@@ -6986,20 +6419,18 @@
{
var idx, jq;
var settings = DataTable.settings;
- var tables = $.map( settings, function (el, i) {
- return el.nTable;
- } );
+ var tables = _pluck(settings, 'nTable');
if ( ! mixed ) {
return [];
}
- else if ( mixed.nTable && mixed.oApi ) {
+ else if ( mixed.nTable && mixed.oFeatures ) {
// DataTables settings object
return [ mixed ];
}
else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
// Table node
- idx = $.inArray( mixed, tables );
+ idx = tables.indexOf(mixed);
return idx !== -1 ? [ settings[idx] ] : null;
}
else if ( mixed && typeof mixed.settings === 'function' ) {
@@ -7007,18 +6438,17 @@
}
else if ( typeof mixed === 'string' ) {
// jQuery selector
- jq = $(mixed);
+ jq = $(mixed).get();
}
else if ( mixed instanceof $ ) {
// jQuery object (also DataTables instance)
- jq = mixed;
+ jq = mixed.get();
}
if ( jq ) {
- return jq.map( function(i) {
- idx = $.inArray( this, tables );
- return idx !== -1 ? settings[idx] : null;
- } ).toArray();
+ return settings.filter(function (v, idx) {
+ return jq.includes(tables[idx]);
+ });
}
};
@@ -7075,7 +6505,7 @@
*
* @example
* // Initialisation as a constructor
- * var api = new $.fn.DataTable.Api( 'table.dataTable' );
+ * var api = new DataTable.Api( 'table.dataTable' );
*/
_Api = function ( context, data )
{
@@ -7101,11 +6531,13 @@
}
// Remove duplicates
- this.context = _unique( settings );
+ this.context = settings.length > 1
+ ? _unique( settings )
+ : settings;
// Initial data
if ( data ) {
- $.merge( this, data );
+ this.push.apply(this, data);
}
// selector
@@ -7128,19 +6560,13 @@
return this.count() !== 0;
},
-
- concat: __arrayProto.concat,
-
-
context: [], // array of table settings objects
-
count: function ()
{
return this.flatten().length;
},
-
each: function ( fn )
{
for ( var i=0, ien=this.length ; i').html( value );
+ ctx.captionNode = caption[0];
- _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
- return this.iterator( 'table', function ( ctx ) {
- return ctx.nTableWrapper;
+ // If side isn't set, we need to insert into the document to let the
+ // CSS decide so we can read it back, otherwise there is no way to
+ // know if the CSS would put it top or bottom for scrolling
+ if (! side) {
+ table.prepend(caption);
+
+ side = caption.css('caption-side');
+ }
+ }
+
+ caption.html( value );
+
+ if ( side ) {
+ caption.css( 'caption-side', side );
+ caption[0]._captionSide = side;
+ }
+
+ if (container.find('div.dataTables_scroll').length) {
+ var selector = (side === 'top' ? 'Head' : 'Foot');
+
+ container.find('div.dataTables_scroll'+ selector +' table').prepend(caption);
+ }
+ else {
+ table.prepend(caption);
+ }
}, 1 );
} );
+ _api_register( 'caption.node()', function () {
+ var ctx = this.context;
+
+ return ctx.length ? ctx[0].captionNode : null;
+ } );
/**
@@ -7709,7 +7148,7 @@
* * `recordsDisplay` - Data set length once the current filtering criterion
* are applied.
*/
- _api_register( 'page.info()', function ( action ) {
+ _api_register( 'page.info()', function () {
if ( this.context.length === 0 ) {
return undefined;
}
@@ -7786,7 +7225,7 @@
}
// Trigger xhr
- _fnBuildAjax( settings, [], function( json ) {
+ _fnBuildAjax( settings, {}, function( json ) {
_fnClearTable( settings );
var data = _fnAjaxDataSrc( settings, json );
@@ -7795,6 +7234,7 @@
}
_fnReDraw( settings, holdPosition );
+ _fnInitComplete( settings );
_fnProcessingDisplay( settings, false );
} );
}
@@ -7871,11 +7311,9 @@
}
ctx = ctx[0];
- return ctx.ajax ?
- $.isPlainObject( ctx.ajax ) ?
- ctx.ajax.url :
- ctx.ajax :
- ctx.sAjaxSource;
+ return $.isPlainObject( ctx.ajax ) ?
+ ctx.ajax.url :
+ ctx.ajax;
}
// set
@@ -7886,9 +7324,6 @@
else {
settings.ajax = url;
}
- // No need to consider sAjaxSource here since DataTables gives priority
- // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
- // value of `sAjaxSource` redundant.
} );
} );
@@ -7928,13 +7363,18 @@
for ( i=0, ien=selector.length ; i 0 ) {
- // Assign the first element to the first item in the instance
- // and truncate the instance and context
- inst[0] = inst[i];
- inst[0].length = 1;
- inst.length = 1;
- inst.context = [ inst.context[i] ];
+ let inst = new _Api(old.context[0]);
- return inst;
- }
+ // Use a push rather than passing to the constructor, since it will
+ // merge arrays down automatically, which isn't what is wanted here
+ if (old.length) {
+ inst.push( old[0] );
+ }
+
+ inst.selector = old.selector;
+
+ // Limit to a single row / column / cell
+ if (inst.length && inst[0].length > 1) {
+ inst[0].splice(1);
}
- // Not found - return an empty instance
- inst.length = 0;
return inst;
};
@@ -8035,24 +7475,28 @@
// O(n+m) solution by creating a hash map
var displayFilteredMap = {};
- for ( var i=0, ien=displayFiltered.length ; i= 0 && search == 'applied') )
@@ -8062,6 +7506,25 @@
}
}
}
+ else if ( typeof order === 'number' ) {
+ // Order the rows by the given column
+ var ordered = _fnSort(settings, order, 'asc');
+
+ if (search === 'none') {
+ a = ordered;
+ }
+ else { // applied | removed
+ for (i=0; i= 0 && search == 'applied') )
+ {
+ a.push( ordered[i] );
+ }
+ }
+ }
+ }
return a;
};
@@ -8082,7 +7545,6 @@
var rows;
var run = function ( sel ) {
var selInt = _intVal( sel );
- var i, ien;
var aoData = settings.aoData;
// Short cut - selector is a number and no options provided (default is
@@ -8096,7 +7558,7 @@
rows = _selector_row_indexes( settings, opts );
}
- if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
+ if ( selInt !== null && rows.indexOf(selInt) !== -1 ) {
// Selector - integer
return [ selInt ];
}
@@ -8107,7 +7569,7 @@
// Selector - function
if ( typeof sel === 'function' ) {
- return $.map( rows, function (idx) {
+ return rows.map( function (idx) {
var row = aoData[ idx ];
return sel( idx, row._aData, row.nTr ) ? idx : null;
} );
@@ -8173,7 +7635,17 @@
.toArray();
};
- return _selector_run( 'row', selector, run, settings, opts );
+ var matched = _selector_run( 'row', selector, run, settings, opts );
+
+ if (opts.order === 'current' || opts.order === 'applied') {
+ var master = settings.aiDisplayMaster;
+
+ matched.sort(function(a, b) {
+ return master.indexOf(a) - master.indexOf(b);
+ });
+ }
+
+ return matched;
};
@@ -8247,38 +7719,20 @@
} );
_api_registerPlural( 'rows().remove()', 'row().remove()', function () {
- var that = this;
-
- this.iterator( 'row', function ( settings, row, thatIdx ) {
+ this.iterator( 'row', function ( settings, row ) {
var data = settings.aoData;
var rowData = data[ row ];
- var i, ien, j, jen;
- var loopRow, loopCells;
-
- data.splice( row, 1 );
-
- // Update the cached indexes
- for ( i=0, ien=data.length ; i 0 ) {
@@ -8293,12 +7747,8 @@
if ( id !== undefined ) {
delete settings.aIds[ id ];
}
- } );
- this.iterator( 'table', function ( settings ) {
- for ( var i=0, ien=settings.aoData.length ; i
').addClass( k );
+ var created = $('
')
+ .attr( 'data-dt-row', row.idx )
+ .addClass( k );
+
$('td', created)
.addClass( k )
- .html( r )
- [0].colSpan = _fnVisbleColumns( ctx );
+ .html( r )[0].colSpan = _fnVisbleColumns( ctx );
rows.push( created[0] );
}
@@ -8566,7 +8024,7 @@
} );
// Column visibility change - update the colspan
- api.on( colvisEvent, function ( e, ctx, idx, vis ) {
+ api.on( colvisEvent, function ( e, ctx ) {
if ( settings !== ctx ) {
return;
}
@@ -8579,7 +8037,13 @@
row = data[i];
if ( row._details ) {
- row._details.children('td[colspan]').attr('colspan', visible );
+ row._details.each(function () {
+ var el = $(this).children('td');
+
+ if (el.length == 1) {
+ el.attr('colspan', visible);
+ }
+ });
}
}
} );
@@ -8637,7 +8101,7 @@
_api_register( [
_child_obj+'.show()',
_child_mth+'.show()' // only when `child()` was called with parameters (without
- ], function ( show ) { // it returns an object and this method is not executed)
+ ], function () { // it returns an object and this method is not executed)
__details_display( this, true );
return this;
} );
@@ -8687,15 +8151,15 @@
// can be an array of these items, comma separated list, or an array of comma
// separated lists
- var __re_column_selector = /^([^:]+):(name|visIdx|visible)$/;
+ var __re_column_selector = /^([^:]+):(name|title|visIdx|visible)$/;
// r1 and r2 are redundant - but it means that the parameters match for the
// iterator callback in columns().data()
- var __columnData = function ( settings, column, r1, r2, rows ) {
+ var __columnData = function ( settings, column, r1, r2, rows, type ) {
var a = [];
for ( var row=0, ien=rows.length ; row').html('
' + Array(columns).join('
') + '
');
+
+ $(this.table().body()).append(row);
+
+ var widths = row.children().map(function () {
+ return $(this).outerWidth();
+ });
+
+ row.remove();
+
+ return this.iterator( 'column', function ( settings, column ) {
+ var visIdx = _fnColumnIndexToVisible( settings, column );
+
+ return visIdx !== null ? widths[visIdx] : 0;
+ }, 1);
+ } );
+
_api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
return this.iterator( 'column', function ( settings, column ) {
return type === 'visible' ?
@@ -9016,7 +8580,7 @@
// Selector - index
if ( $.isPlainObject( s ) ) {
// Valid cell index and its in the array of selectable rows
- return s.column !== undefined && s.row !== undefined && $.inArray( s.row, rows ) !== -1 ?
+ return s.column !== undefined && s.row !== undefined && rows.indexOf(s.row) !== -1 ?
[s] :
[];
}
@@ -9028,7 +8592,7 @@
return { // use a new object, in case someone changes the values
row: el._DT_CellIndex.row,
column: el._DT_CellIndex.column
- };
+ };
} )
.toArray();
@@ -9233,6 +8797,7 @@
*/
_api_register( 'order()', function ( order, dir ) {
var ctx = this.context;
+ var args = Array.prototype.slice.call( arguments );
if ( order === undefined ) {
// get
@@ -9246,14 +8811,14 @@
// Simple column / direction passed in
order = [ [ order, dir ] ];
}
- else if ( order.length && ! Array.isArray( order[0] ) ) {
+ else if ( args.length > 1 ) {
// Arguments passed in (list of 1D arrays)
- order = Array.prototype.slice.call( arguments );
+ order = args;
}
// otherwise a 2D array was passed in
return this.iterator( 'table', function ( settings ) {
- settings.aaSorting = order.slice();
+ settings.aaSorting = Array.isArray(order) ? order.slice() : order;
} );
} );
@@ -9270,7 +8835,7 @@
*/
_api_register( 'order.listener()', function ( node, column, callback ) {
return this.iterator( 'table', function ( settings ) {
- _fnSortAttachListener( settings, node, column, callback );
+ _fnSortAttachListener(settings, node, {}, column, callback);
} );
} );
@@ -9300,18 +8865,45 @@
], function ( dir ) {
var that = this;
- return this.iterator( 'table', function ( settings, i ) {
- var sort = [];
+ if ( ! dir ) {
+ return this.iterator( 'column', function ( settings, idx ) {
+ var sort = _fnSortFlatten( settings );
+
+ for ( var i=0, ien=sort.length ; iEmpty string
*/
- "sSearch": "",
+ "search": "",
/**
* Flag to indicate if the search term should be interpreted as a
* regular expression (true) or not (false) and therefore and special
* regex characters escaped.
- * @type boolean
- * @default false
*/
- "bRegex": false,
+ "regex": false,
/**
* Flag to indicate if DataTables is to use its smart filtering or not.
- * @type boolean
- * @default true
*/
- "bSmart": true,
+ "smart": true,
/**
* Flag to indicate if DataTables should only trigger a search when
* the return key is pressed.
- * @type boolean
- * @default false
*/
"return": false
};
@@ -9874,16 +9574,12 @@
DataTable.models.oRow = {
/**
* TR element for the row
- * @type node
- * @default null
*/
"nTr": null,
/**
* Array of TD elements for each row. This is null until the row has been
* created.
- * @type array nodes
- * @default []
*/
"anCells": null,
@@ -9893,8 +9589,6 @@
* using mData options. The exact type will depend on the passed in
* data from the data source, or will be an array if using DOM a data
* source.
- * @type array|object
- * @default []
*/
"_aData": [],
@@ -9906,18 +9600,12 @@
* the formatting of the sort data need be done only once for each cell
* per sort. This array should not be read from or written to by anything
* other than the master sorting methods.
- * @type array
- * @default null
- * @private
*/
"_aSortData": null,
/**
* Per cell filtering data cache. As per the sort data cache, used to
* increase the performance of the filtering in DataTables
- * @type array
- * @default null
- * @private
*/
"_aFilterData": null,
@@ -9926,41 +9614,27 @@
* in this case a string rather than an array. This is easily computed with
* a join on `_aFilterData`, but is provided as a cache so the join isn't
* needed on every search (memory traded for performance)
- * @type array
- * @default null
- * @private
*/
"_sFilterRow": null,
- /**
- * Cache of the class name that DataTables has applied to the row, so we
- * can quickly look at this variable rather than needing to do a DOM check
- * on className for the nTr property.
- * @type string
- * @default Empty string
- * @private
- */
- "_sRowStripe": "",
-
/**
* Denote if the original data source was from the DOM, or the data source
* object. This is used for invalidating data, so DataTables can
* automatically read data from the original source, unless uninstructed
* otherwise.
- * @type string
- * @default null
- * @private
*/
"src": null,
/**
* Index in the aoData array. This saves an indexOf lookup when we have the
* object, but want to know the index
- * @type integer
- * @default -1
- * @private
*/
- "idx": -1
+ "idx": -1,
+
+ /**
+ * Cached display value
+ */
+ displayData: null
};
@@ -9977,10 +9651,7 @@
*/
DataTable.models.oColumn = {
/**
- * Column index. This could be worked out on-the-fly with $.inArray, but it
- * is faster to just hold it as a variable
- * @type integer
- * @default null
+ * Column index.
*/
"idx": null,
@@ -9991,7 +9662,6 @@
* would benefit from this). The values are integers pointing to the
* columns to be sorted on (typically it will be a single integer pointing
* at itself, but that doesn't need to be the case).
- * @type array
*/
"aDataSort": null,
@@ -10001,44 +9671,34 @@
* as the sorting direction when the column if first sorted (clicked on).
* Sort it again (click again) and it will move on to the next index.
* Repeat until loop.
- * @type array
*/
"asSorting": null,
/**
* Flag to indicate if the column is searchable, and thus should be included
* in the filtering or not.
- * @type boolean
*/
"bSearchable": null,
/**
* Flag to indicate if the column is sortable or not.
- * @type boolean
*/
"bSortable": null,
/**
* Flag to indicate if the column is currently visible in the table or not
- * @type boolean
*/
"bVisible": null,
/**
* Store for manual type assignment using the `column.type` option. This
* is held in store so we can manipulate the column's `sType` property.
- * @type string
- * @default null
- * @private
*/
"_sManualType": null,
/**
* Flag to indicate if HTML5 data attributes should be used as the data
* source for filtering or sorting. True is either are.
- * @type boolean
- * @default false
- * @private
*/
"_bAttrSrc": false,
@@ -10047,12 +9707,6 @@
* etc) or processed for input (DOM source). This can be used as a compliment to mRender
* allowing you to modify the DOM element (add background colour for example) when the
* element is available.
- * @type function
- * @param {element} nTd The TD node that has been created
- * @param {*} sData The Data for the cell
- * @param {array|object} oData The data for the whole row
- * @param {int} iRow The row index for the aoData data store
- * @default null
*/
"fnCreatedCell": null,
@@ -10062,13 +9716,6 @@
* the method attached to this property. It allows mData to function as
* required. This function is automatically assigned by the column
* initialisation method
- * @type function
- * @param {array|object} oData The data array/object for the array
- * (i.e. aoData[]._aData)
- * @param {string} sSpecific The specific data type you want to get -
- * 'display', 'type' 'filter' 'sort'
- * @returns {*} The data for the cell from the given row's data
- * @default null
*/
"fnGetData": null,
@@ -10077,11 +9724,6 @@
* set the data directly to _aData internally in DataTables - always use
* this method. It allows mData to function as required. This function
* is automatically assigned by the column initialisation method
- * @type function
- * @param {array|object} oData The data array/object for the array
- * (i.e. aoData[]._aData)
- * @param {*} sValue Value to set
- * @default null
*/
"fnSetData": null,
@@ -10089,8 +9731,6 @@
* Property to read the value for the cells in the column from the data
* source array / object. If null, then the default content is used, if a
* function is given then the return from the function is used.
- * @type function|int|string|null
- * @default null
*/
"mData": null,
@@ -10099,32 +9739,11 @@
* the data - i.e. it is basically the same as mData, but without the
* 'set' option, and also the data fed to it is the result from mData.
* This is the rendering method to match the data method of mData.
- * @type function|int|string|null
- * @default null
*/
"mRender": null,
- /**
- * Unique header TH/TD element for this column - this is what the sorting
- * listener is attached to (if sorting is enabled.)
- * @type node
- * @default null
- */
- "nTh": null,
-
- /**
- * Unique footer TH/TD element for this column (if there is one). Not used
- * in DataTables as such, but can be used for plug-ins to reference the
- * footer for each column.
- * @type node
- * @default null
- */
- "nTf": null,
-
/**
* The class to apply to all TD elements in the table's TBODY for the column
- * @type string
- * @default null
*/
"sClass": null,
@@ -10137,7 +9756,6 @@
* it into an DOM object and measuring that is horribly(!) slow). Thus as
* a "work around" we provide this option. It will append its value to the
* text that is found to be the longest string for the column - i.e. padding.
- * @type string
*/
"sContentPadding": null,
@@ -10145,67 +9763,53 @@
* Allows a default value to be given for a column's data, and will be used
* whenever a null data source is encountered (this can be because mData
* is set to null, or because the data source itself is null).
- * @type string
- * @default null
*/
"sDefaultContent": null,
/**
* Name for the column, allowing reference to the column by name as well as
* by index (needs a lookup to work by name).
- * @type string
*/
"sName": null,
/**
* Custom sorting data type - defines which of the available plug-ins in
* afnSortData the custom sorting will use - if any is defined.
- * @type string
- * @default std
*/
"sSortDataType": 'std',
/**
* Class to be applied to the header element when sorting on this column
- * @type string
- * @default null
*/
"sSortingClass": null,
- /**
- * Class to be applied to the header element when sorting on this column -
- * when jQuery UI theming is used.
- * @type string
- * @default null
- */
- "sSortingClassJUI": null,
-
/**
* Title of the column - what is seen in the TH element (nTh).
- * @type string
*/
"sTitle": null,
/**
* Column sorting and filtering type
- * @type string
- * @default null
*/
"sType": null,
/**
* Width of the column
- * @type string
- * @default null
*/
"sWidth": null,
/**
* Width of the column when it was first "encountered"
- * @type string
- * @default null
*/
- "sWidthOrig": null
+ "sWidthOrig": null,
+
+ /** Cached string which is the longest in the column */
+ maxLenString: null,
+
+ /**
+ * Store for named searches
+ */
+ searchFixed: null
};
@@ -10236,59 +9840,6 @@
* will be used in preference to any data which is already in the DOM. This is
* particularly useful for constructing tables purely in Javascript, for
* example with a custom Ajax call.
- * @type array
- * @default null
- *
- * @dtopt Option
- * @name DataTable.defaults.data
- *
- * @example
- * // Using a 2D array data source
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "data": [
- * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
- * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
- * ],
- * "columns": [
- * { "title": "Engine" },
- * { "title": "Browser" },
- * { "title": "Platform" },
- * { "title": "Version" },
- * { "title": "Grade" }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using an array of objects as a data source (`data`)
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "data": [
- * {
- * "engine": "Trident",
- * "browser": "Internet Explorer 4.0",
- * "platform": "Win 95+",
- * "version": 4,
- * "grade": "X"
- * },
- * {
- * "engine": "Trident",
- * "browser": "Internet Explorer 5.0",
- * "platform": "Win 95+",
- * "version": 5,
- * "grade": "C"
- * }
- * ],
- * "columns": [
- * { "title": "Engine", "data": "engine" },
- * { "title": "Browser", "data": "browser" },
- * { "title": "Platform", "data": "platform" },
- * { "title": "Version", "data": "version" },
- * { "title": "Grade", "data": "grade" }
- * ]
- * } );
- * } );
*/
"aaData": null,
@@ -10299,26 +9850,6 @@
* upon, and the sorting direction, with this variable. The `sorting` array
* should contain an array for each column to be sorted initially containing
* the column's index and a direction string ('asc' or 'desc').
- * @type array
- * @default [[0,'asc']]
- *
- * @dtopt Option
- * @name DataTable.defaults.order
- *
- * @example
- * // Sort by 3rd column first, and then 4th column
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "order": [[2,'asc'], [3,'desc']]
- * } );
- * } );
- *
- * // No initial sorting
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "order": []
- * } );
- * } );
*/
"aaSorting": [[0,'asc']],
@@ -10330,18 +9861,6 @@
* will always be forced on first - any sorting after that (from the user)
* will then be performed as required. This can be useful for grouping rows
* together.
- * @type array
- * @default null
- *
- * @dtopt Option
- * @name DataTable.defaults.orderFixed
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "orderFixed": [[0,'asc']]
- * } );
- * } )
*/
"aaSortingFixed": [],
@@ -10367,7 +9886,7 @@
* --------
*
* As an object, the parameters in the object are passed to
- * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
+ * [jQuery.ajax](https://api.jquery.com/jQuery.ajax/) allowing fine control
* of the Ajax request. DataTables has a number of default parameters which
* you can override using this option. Please refer to the jQuery
* documentation for a full description of the options available, although
@@ -10391,8 +9910,7 @@
* it my be used as a function. As a function it takes a single parameter,
* the JSON returned from the server, which can be manipulated as
* required, with the returned value being that used by DataTables as the
- * data source for the table. This supersedes `sAjaxDataProp` from
- * DataTables 1.9-.
+ * data source for the table.
*
* * `success` - Should not be overridden it is used internally in
* DataTables. To manipulate / transform the data returned by the server
@@ -10414,91 +9932,6 @@
* data has been obtained. That data should be passed into the callback
* as the only parameter
* 3. _object_ - DataTables settings object for the table
- *
- * Note that this supersedes `fnServerData` from DataTables 1.9-.
- *
- * @type string|object|function
- * @default null
- *
- * @dtopt Option
- * @name DataTable.defaults.ajax
- * @since 1.10.0
- *
- * @example
- * // Get JSON data from a file via Ajax.
- * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
- * $('#example').dataTable( {
- * "ajax": "data.json"
- * } );
- *
- * @example
- * // Get JSON data from a file via Ajax, using `dataSrc` to change
- * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
- * $('#example').dataTable( {
- * "ajax": {
- * "url": "data.json",
- * "dataSrc": "tableData"
- * }
- * } );
- *
- * @example
- * // Get JSON data from a file via Ajax, using `dataSrc` to read data
- * // from a plain array rather than an array in an object
- * $('#example').dataTable( {
- * "ajax": {
- * "url": "data.json",
- * "dataSrc": ""
- * }
- * } );
- *
- * @example
- * // Manipulate the data returned from the server - add a link to data
- * // (note this can, should, be done using `render` for the column - this
- * // is just a simple example of how the data can be manipulated).
- * $('#example').dataTable( {
- * "ajax": {
- * "url": "data.json",
- * "dataSrc": function ( json ) {
- * for ( var i=0, ien=json.length ; ia negative integer - column index counting from the right
*
the string "_all" - all columns (i.e. assign a default)
*
- * @member
- *
- * @name DataTable.defaults.columnDefs
*/
"aoColumnDefs": null,
@@ -10571,64 +9986,14 @@
* as the number of columns, and each element be an object with the parameters
* `search` and `escapeRegex` (the latter is optional). 'null' is also
* accepted and the default will be used.
- * @type array
- * @default []
- *
- * @dtopt Option
- * @name DataTable.defaults.searchCols
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "searchCols": [
- * null,
- * { "search": "My filter" },
- * null,
- * { "search": "^[0-9]", "escapeRegex": false }
- * ]
- * } );
- * } )
*/
"aoSearchCols": [],
- /**
- * An array of CSS classes that should be applied to displayed rows. This
- * array may be of any length, and DataTables will apply each class
- * sequentially, looping when required.
- * @type array
- * @default null Will take the values determined by the `oClasses.stripe*`
- * options
- *
- * @dtopt Option
- * @name DataTable.defaults.stripeClasses
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
- * } );
- * } )
- */
- "asStripeClasses": null,
-
-
/**
* Enable or disable automatic column width calculation. This can be disabled
* as an optimisation (it takes some time to calculate the widths) if the
* tables widths are passed in using `columns`.
- * @type boolean
- * @default true
- *
- * @dtopt Features
- * @name DataTable.defaults.autoWidth
- *
- * @example
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "autoWidth": false
- * } );
- * } );
*/
"bAutoWidth": true,
@@ -10639,21 +10004,8 @@
* true, will cause DataTables to defer the creation of the table elements for
* each row until they are needed for a draw - saving a significant amount of
* time.
- * @type boolean
- * @default false
- *
- * @dtopt Features
- * @name DataTable.defaults.deferRender
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "ajax": "sources/arrays.txt",
- * "deferRender": true
- * } );
- * } );
*/
- "bDeferRender": false,
+ "bDeferRender": true,
/**
@@ -10661,25 +10013,6 @@
* one which has the properties of the new initialisation object passed. If no
* table matches the selector, then the new DataTable will be constructed as
* per normal.
- * @type boolean
- * @default false
- *
- * @dtopt Options
- * @name DataTable.defaults.destroy
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "srollY": "200px",
- * "paginate": false
- * } );
- *
- * // Some time later....
- * $('#example').dataTable( {
- * "filter": false,
- * "destroy": true
- * } );
- * } );
*/
"bDestroy": false,
@@ -10692,75 +10025,23 @@
* wish to use filtering in DataTables this must remain 'true' - to remove the
* default filtering input box and retain filtering abilities, please use
* {@link DataTable.defaults.dom}.
- * @type boolean
- * @default true
- *
- * @dtopt Features
- * @name DataTable.defaults.searching
- *
- * @example
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "searching": false
- * } );
- * } );
*/
"bFilter": true,
-
/**
- * Enable or disable the table information display. This shows information
- * about the data that is currently visible on the page, including information
- * about filtered data if that action is being performed.
- * @type boolean
- * @default true
- *
- * @dtopt Features
- * @name DataTable.defaults.info
- *
- * @example
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "info": false
- * } );
- * } );
+ * Used only for compatiblity with DT1
+ * @deprecated
*/
"bInfo": true,
-
/**
- * Allows the end user to select the size of a formatted page from a select
- * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
- * @type boolean
- * @default true
- *
- * @dtopt Features
- * @name DataTable.defaults.lengthChange
- *
- * @example
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "lengthChange": false
- * } );
- * } );
+ * Used only for compatiblity with DT1
+ * @deprecated
*/
"bLengthChange": true,
-
/**
* Enable or disable pagination.
- * @type boolean
- * @default true
- *
- * @dtopt Features
- * @name DataTable.defaults.paging
- *
- * @example
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "paging": false
- * } );
- * } );
*/
"bPaginate": true,
@@ -10770,18 +10051,6 @@
* being processed (e.g. a sort). This is particularly useful for tables with
* large amounts of data where it can take a noticeable amount of time to sort
* the entries.
- * @type boolean
- * @default false
- *
- * @dtopt Features
- * @name DataTable.defaults.processing
- *
- * @example
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "processing": true
- * } );
- * } );
*/
"bProcessing": false,
@@ -10794,32 +10063,6 @@
* passed to DataTables (setting this parameter to true is an acknowledgement
* that you understand this). `destroy` can be used to reinitialise a table if
* you need.
- * @type boolean
- * @default false
- *
- * @dtopt Options
- * @name DataTable.defaults.retrieve
- *
- * @example
- * $(document).ready( function() {
- * initTable();
- * tableActions();
- * } );
- *
- * function initTable ()
- * {
- * return $('#example').dataTable( {
- * "scrollY": "200px",
- * "paginate": false,
- * "retrieve": true
- * } );
- * }
- *
- * function tableActions ()
- * {
- * var table = initTable();
- * // perform API operations with oTable
- * }
*/
"bRetrieve": false,
@@ -10831,19 +10074,6 @@
* and the footer is left "floating" further down. This parameter (when
* enabled) will cause DataTables to collapse the table's viewport down when
* the result set will fit within the given Y height.
- * @type boolean
- * @default false
- *
- * @dtopt Options
- * @name DataTable.defaults.scrollCollapse
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "scrollY": "200",
- * "scrollCollapse": true
- * } );
- * } );
*/
"bScrollCollapse": false,
@@ -10852,20 +10082,6 @@
* Configure DataTables to use server-side processing. Note that the
* `ajax` parameter must also be given in order to give DataTables a
* source to obtain the required data for each draw.
- * @type boolean
- * @default false
- *
- * @dtopt Features
- * @dtopt Server-side
- * @name DataTable.defaults.serverSide
- *
- * @example
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "serverSide": true,
- * "ajax": "xhr.php"
- * } );
- * } );
*/
"bServerSide": false,
@@ -10873,18 +10089,6 @@
/**
* Enable or disable sorting of columns. Sorting of individual columns can be
* disabled by the `sortable` option for each column.
- * @type boolean
- * @default true
- *
- * @dtopt Features
- * @name DataTable.defaults.ordering
- *
- * @example
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "ordering": false
- * } );
- * } );
*/
"bSort": true,
@@ -10892,19 +10096,6 @@
/**
* Enable or display DataTables' ability to sort multiple columns at the
* same time (activated by shift-click by the user).
- * @type boolean
- * @default true
- *
- * @dtopt Options
- * @name DataTable.defaults.orderMulti
- *
- * @example
- * // Disable multiple column sorting ability
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "orderMulti": false
- * } );
- * } );
*/
"bSortMulti": true,
@@ -10913,20 +10104,8 @@
* Allows control over whether DataTables should use the top (true) unique
* cell that is found for a single column, or the bottom (false - default).
* This is useful when using complex headers.
- * @type boolean
- * @default false
- *
- * @dtopt Options
- * @name DataTable.defaults.orderCellsTop
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "orderCellsTop": true
- * } );
- * } );
*/
- "bSortCellsTop": false,
+ "bSortCellsTop": null,
/**
@@ -10935,18 +10114,6 @@
* presented as a feature switch as it can increase processing time (while
* classes are removed and added) so for large data sets you might want to
* turn this off.
- * @type boolean
- * @default true
- *
- * @dtopt Features
- * @name DataTable.defaults.orderClasses
- *
- * @example
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "orderClasses": false
- * } );
- * } );
*/
"bSortClasses": true,
@@ -10956,22 +10123,6 @@
* used to save table display information such as pagination information,
* display length, filtering and sorting. As such when the end user reloads
* the page the display display will match what thy had previously set up.
- *
- * Due to the use of `localStorage` the default state saving is not supported
- * in IE6 or 7. If state saving is required in those browsers, use
- * `stateSaveCallback` to provide a storage solution such as cookies.
- * @type boolean
- * @default false
- *
- * @dtopt Features
- * @name DataTable.defaults.stateSave
- *
- * @example
- * $(document).ready( function () {
- * $('#example').dataTable( {
- * "stateSave": true
- * } );
- * } );
*/
"bStateSave": false,
@@ -10980,26 +10131,6 @@
* This function is called when a TR element is created (and all TD child
* elements have been inserted), or registered if using a DOM source, allowing
* manipulation of the TR element (adding classes etc).
- * @type function
- * @param {node} row "TR" element for the current row
- * @param {array} data Raw data array for this row
- * @param {int} dataIndex The index of this row in the internal aoData array
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.createdRow
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "createdRow": function( row, data, dataIndex ) {
- * // Bold the grade for all 'A' grade browsers
- * if ( data[4] == "A" )
- * {
- * $('td:eq(4)', row).html( 'A' );
- * }
- * }
- * } );
- * } );
*/
"fnCreatedRow": null,
@@ -11007,20 +10138,6 @@
/**
* This function is called on every 'draw' event, and allows you to
* dynamically modify any aspect you want about the created DOM.
- * @type function
- * @param {object} settings DataTables settings object
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.drawCallback
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "drawCallback": function( settings ) {
- * alert( 'DataTables has redrawn the table' );
- * }
- * } );
- * } );
*/
"fnDrawCallback": null,
@@ -11028,27 +10145,6 @@
/**
* Identical to fnHeaderCallback() but for the table footer this function
* allows you to modify the table footer on every 'draw' event.
- * @type function
- * @param {node} foot "TR" element for the footer
- * @param {array} data Full table data (as derived from the original HTML)
- * @param {int} start Index for the current display starting point in the
- * display array
- * @param {int} end Index for the current display ending point in the
- * display array
- * @param {array int} display Index array to translate the visual position
- * to the full data array
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.footerCallback
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "footerCallback": function( tfoot, data, start, end, display ) {
- * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
- * }
- * } );
- * } )
*/
"fnFooterCallback": null,
@@ -11059,26 +10155,6 @@
* to have a comma separator for the 'thousands' units (e.g. 1 million is
* rendered as "1,000,000") to help readability for the end user. This
* function will override the default method DataTables uses.
- * @type function
- * @member
- * @param {int} toFormat number to be formatted
- * @returns {string} formatted string for DataTables to show the number
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.formatNumber
- *
- * @example
- * // Format a number using a single quote for the separator (note that
- * // this can also be done with the language.thousands option)
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "formatNumber": function ( toFormat ) {
- * return toFormat.toString().replace(
- * /\B(?=(\d{3})+(?!\d))/g, "'"
- * );
- * };
- * } );
- * } );
*/
"fnFormatNumber": function ( toFormat ) {
return toFormat.toString().replace(
@@ -11092,27 +10168,6 @@
* This function is called on every 'draw' event, and allows you to
* dynamically modify the header row. This can be used to calculate and
* display useful information about the table.
- * @type function
- * @param {node} head "TR" element for the header
- * @param {array} data Full table data (as derived from the original HTML)
- * @param {int} start Index for the current display starting point in the
- * display array
- * @param {int} end Index for the current display ending point in the
- * display array
- * @param {array int} display Index array to translate the visual position
- * to the full data array
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.headerCallback
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "fheaderCallback": function( head, data, start, end, display ) {
- * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
- * }
- * } );
- * } )
*/
"fnHeaderCallback": null,
@@ -11123,26 +10178,6 @@
* DataTables are quite capable of dealing with most customisations, there may
* be times where you wish to customise the string further. This callback
* allows you to do exactly that.
- * @type function
- * @param {object} oSettings DataTables settings object
- * @param {int} start Starting position in data for the draw
- * @param {int} end End position in data for the draw
- * @param {int} max Total number of rows in the table (regardless of
- * filtering)
- * @param {int} total Total number of rows in the data set, after filtering
- * @param {string} pre The string that DataTables has formatted using it's
- * own rules
- * @returns {string} The string to be displayed in the information element.
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.infoCallback
- *
- * @example
- * $('#example').dataTable( {
- * "infoCallback": function( settings, start, end, max, total, pre ) {
- * return start +" to "+ end;
- * }
- * } );
*/
"fnInfoCallback": null,
@@ -11152,22 +10187,6 @@
* initialise sequentially and there will be no need for this function,
* however, this does not hold true when using external language information
* since that is obtained using an async XHR call.
- * @type function
- * @param {object} settings DataTables settings object
- * @param {object} json The JSON object request from the server - only
- * present if client-side Ajax sourced data is used
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.initComplete
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "initComplete": function(settings, json) {
- * alert( 'DataTables has finished its initialisation.' );
- * }
- * } );
- * } )
*/
"fnInitComplete": null,
@@ -11176,24 +10195,6 @@
* Called at the very start of each table draw and can be used to cancel the
* draw by returning false, any other return (including undefined) results in
* the full draw occurring).
- * @type function
- * @param {object} settings DataTables settings object
- * @returns {boolean} False will cancel the draw, anything else (including no
- * return) will allow it to complete.
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.preDrawCallback
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "preDrawCallback": function( settings ) {
- * if ( $('#test').val() == 1 ) {
- * return false;
- * }
- * }
- * } );
- * } );
*/
"fnPreDrawCallback": null,
@@ -11202,113 +10203,14 @@
* This function allows you to 'post process' each row after it have been
* generated for each table draw, but before it is rendered on screen. This
* function might be used for setting the row class name etc.
- * @type function
- * @param {node} row "TR" element for the current row
- * @param {array} data Raw data array for this row
- * @param {int} displayIndex The display index for the current table draw
- * @param {int} displayIndexFull The index of the data in the full list of
- * rows (after filtering)
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.rowCallback
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
- * // Bold the grade for all 'A' grade browsers
- * if ( data[4] == "A" ) {
- * $('td:eq(4)', row).html( 'A' );
- * }
- * }
- * } );
- * } );
*/
"fnRowCallback": null,
- /**
- * __Deprecated__ The functionality provided by this parameter has now been
- * superseded by that provided through `ajax`, which should be used instead.
- *
- * This parameter allows you to override the default function which obtains
- * the data from the server so something more suitable for your application.
- * For example you could use POST data, or pull information from a Gears or
- * AIR database.
- * @type function
- * @member
- * @param {string} source HTTP source to obtain the data from (`ajax`)
- * @param {array} data A key/value pair object containing the data to send
- * to the server
- * @param {function} callback to be called on completion of the data get
- * process that will draw the data on the page.
- * @param {object} settings DataTables settings object
- *
- * @dtopt Callbacks
- * @dtopt Server-side
- * @name DataTable.defaults.serverData
- *
- * @deprecated 1.10. Please use `ajax` for this functionality now.
- */
- "fnServerData": null,
-
-
- /**
- * __Deprecated__ The functionality provided by this parameter has now been
- * superseded by that provided through `ajax`, which should be used instead.
- *
- * It is often useful to send extra data to the server when making an Ajax
- * request - for example custom filtering information, and this callback
- * function makes it trivial to send extra information to the server. The
- * passed in parameter is the data set that has been constructed by
- * DataTables, and you can add to this or modify it as you require.
- * @type function
- * @param {array} data Data array (array of objects which are name/value
- * pairs) that has been constructed by DataTables and will be sent to the
- * server. In the case of Ajax sourced data with server-side processing
- * this will be an empty array, for server-side processing there will be a
- * significant number of parameters!
- * @returns {undefined} Ensure that you modify the data array passed in,
- * as this is passed by reference.
- *
- * @dtopt Callbacks
- * @dtopt Server-side
- * @name DataTable.defaults.serverParams
- *
- * @deprecated 1.10. Please use `ajax` for this functionality now.
- */
- "fnServerParams": null,
-
-
/**
* Load the table state. With this function you can define from where, and how, the
* state of a table is loaded. By default DataTables will load from `localStorage`
* but you might wish to use a server-side database or cookies.
- * @type function
- * @member
- * @param {object} settings DataTables settings object
- * @param {object} callback Callback that can be executed when done. It
- * should be passed the loaded state object.
- * @return {object} The DataTables state object to be loaded
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.stateLoadCallback
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "stateSave": true,
- * "stateLoadCallback": function (settings, callback) {
- * $.ajax( {
- * "url": "/state_load",
- * "dataType": "json",
- * "success": function (json) {
- * callback( json );
- * }
- * } );
- * }
- * } );
- * } );
*/
"fnStateLoadCallback": function ( settings ) {
try {
@@ -11323,40 +10225,12 @@
},
- /**
- * Callback which allows modification of the saved state prior to loading that state.
- * This callback is called when the table is loading state from the stored data, but
- * prior to the settings object being modified by the saved state. Note that for
- * plug-in authors, you should use the `stateLoadParams` event to load parameters for
- * a plug-in.
- * @type function
- * @param {object} settings DataTables settings object
- * @param {object} data The state object that is to be loaded
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.stateLoadParams
- *
- * @example
- * // Remove a saved filter, so filtering is never loaded
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "stateSave": true,
- * "stateLoadParams": function (settings, data) {
- * data.oSearch.sSearch = "";
- * }
- * } );
- * } );
- *
- * @example
- * // Disallow state loading by returning false
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "stateSave": true,
- * "stateLoadParams": function (settings, data) {
- * return false;
- * }
- * } );
- * } );
+ /**
+ * Callback which allows modification of the saved state prior to loading that state.
+ * This callback is called when the table is loading state from the stored data, but
+ * prior to the settings object being modified by the saved state. Note that for
+ * plug-in authors, you should use the `stateLoadParams` event to load parameters for
+ * a plug-in.
*/
"fnStateLoadParams": null,
@@ -11364,23 +10238,6 @@
/**
* Callback that is called when the state has been loaded from the state saving method
* and the DataTables settings object has been modified as a result of the loaded state.
- * @type function
- * @param {object} settings DataTables settings object
- * @param {object} data The state object that was loaded
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.stateLoaded
- *
- * @example
- * // Show an alert with the filtering value that was saved
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "stateSave": true,
- * "stateLoaded": function (settings, data) {
- * alert( 'Saved filter was: '+data.oSearch.sSearch );
- * }
- * } );
- * } );
*/
"fnStateLoaded": null,
@@ -11389,30 +10246,6 @@
* Save the table state. This function allows you to define where and how the state
* information for the table is stored By default DataTables will use `localStorage`
* but you might wish to use a server-side database or cookies.
- * @type function
- * @member
- * @param {object} settings DataTables settings object
- * @param {object} data The state object to be saved
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.stateSaveCallback
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "stateSave": true,
- * "stateSaveCallback": function (settings, data) {
- * // Send an Ajax request to the server with the state object
- * $.ajax( {
- * "url": "/state_save",
- * "data": data,
- * "dataType": "json",
- * "method": "POST"
- * "success": function () {}
- * } );
- * }
- * } );
- * } );
*/
"fnStateSaveCallback": function ( settings, data ) {
try {
@@ -11420,7 +10253,9 @@
'DataTables_'+settings.sInstance+'_'+location.pathname,
JSON.stringify( data )
);
- } catch (e) {}
+ } catch (e) {
+ // noop
+ }
},
@@ -11430,23 +10265,6 @@
* the state saving object prior to actually doing the save, including addition or
* other state properties or modification. Note that for plug-in authors, you should
* use the `stateSaveParams` event to save parameters for a plug-in.
- * @type function
- * @param {object} settings DataTables settings object
- * @param {object} data The state object to be saved
- *
- * @dtopt Callbacks
- * @name DataTable.defaults.stateSaveParams
- *
- * @example
- * // Remove a saved filter, so filtering is never saved
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "stateSave": true,
- * "stateSaveParams": function (settings, data) {
- * data.oSearch.sSearch = "";
- * }
- * } );
- * } );
*/
"fnStateSaveParams": null,
@@ -11455,82 +10273,14 @@
* Duration for which the saved state information is considered valid. After this period
* has elapsed the state will be returned to the default.
* Value is given in seconds.
- * @type int
- * @default 7200 (2 hours)
- *
- * @dtopt Options
- * @name DataTable.defaults.stateDuration
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "stateDuration": 60*60*24; // 1 day
- * } );
- * } )
*/
"iStateDuration": 7200,
- /**
- * When enabled DataTables will not make a request to the server for the first
- * page draw - rather it will use the data already on the page (no sorting etc
- * will be applied to it), thus saving on an XHR at load time. `deferLoading`
- * is used to indicate that deferred loading is required, but it is also used
- * to tell DataTables how many records there are in the full table (allowing
- * the information element and pagination to be displayed correctly). In the case
- * where a filtering is applied to the table on initial load, this can be
- * indicated by giving the parameter as an array, where the first element is
- * the number of records available after filtering and the second element is the
- * number of records without filtering (allowing the table information element
- * to be shown correctly).
- * @type int | array
- * @default null
- *
- * @dtopt Options
- * @name DataTable.defaults.deferLoading
- *
- * @example
- * // 57 records available in the table, no filtering applied
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "serverSide": true,
- * "ajax": "scripts/server_processing.php",
- * "deferLoading": 57
- * } );
- * } );
- *
- * @example
- * // 57 records after filtering, 100 without filtering (an initial filter applied)
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "serverSide": true,
- * "ajax": "scripts/server_processing.php",
- * "deferLoading": [ 57, 100 ],
- * "search": {
- * "search": "my_filter"
- * }
- * } );
- * } );
- */
- "iDeferLoading": null,
-
-
/**
* Number of rows to display on a single page when using pagination. If
* feature enabled (`lengthChange`) then the end user will be able to override
* this to a custom setting using a pop-up menu.
- * @type int
- * @default 10
- *
- * @dtopt Options
- * @name DataTable.defaults.pageLength
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "pageLength": 50
- * } );
- * } )
*/
"iDisplayLength": 10,
@@ -11540,18 +10290,6 @@
* pagination. Note that this parameter is the number of records, rather than
* the page number, so if you have 10 records per page and want to start on
* the third page, it should be "20".
- * @type int
- * @default 0
- *
- * @dtopt Options
- * @name DataTable.defaults.displayStart
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "displayStart": 20
- * } );
- * } )
*/
"iDisplayStart": 0,
@@ -11563,18 +10301,6 @@
* The tabindex is default 0, meaning that the tab follows the flow of the document.
* You can overrule this using this parameter if you wish. Use a value of -1 to
* disable built-in keyboard navigation.
- * @type int
- * @default 0
- *
- * @dtopt Options
- * @name DataTable.defaults.tabIndex
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "tabIndex": 1
- * } );
- * } );
*/
"iTabIndex": 0,
@@ -11584,8 +10310,6 @@
* that it adds to the HTML table. This allows classes to be configured
* during initialisation in addition to through the static
* {@link DataTable.ext.oStdClasses} object).
- * @namespace
- * @name DataTable.defaults.classes
*/
"oClasses": {},
@@ -11594,162 +10318,70 @@
* All strings that DataTables uses in the user interface that it creates
* are defined in this object, allowing you to modified them individually or
* completely replace them all as required.
- * @namespace
- * @name DataTable.defaults.language
*/
"oLanguage": {
/**
* Strings that are used for WAI-ARIA labels and controls only (these are not
* actually visible on the page, but will be read by screenreaders, and thus
* must be internationalised as well).
- * @namespace
- * @name DataTable.defaults.language.aria
*/
"oAria": {
/**
- * ARIA label that is added to the table headers when the column may be
- * sorted ascending by activing the column (click or return when focused).
- * Note that the column header is prefixed to this string.
- * @type string
- * @default : activate to sort column ascending
- *
- * @dtopt Language
- * @name DataTable.defaults.language.aria.sortAscending
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "aria": {
- * "sortAscending": " - click/return to sort ascending"
- * }
- * }
- * } );
- * } );
+ * ARIA label that is added to the table headers when the column may be sorted
+ */
+ "orderable": ": Activate to sort",
+
+ /**
+ * ARIA label that is added to the table headers when the column is currently being sorted
*/
- "sSortAscending": ": activate to sort column ascending",
+ "orderableReverse": ": Activate to invert sorting",
/**
- * ARIA label that is added to the table headers when the column may be
- * sorted descending by activing the column (click or return when focused).
- * Note that the column header is prefixed to this string.
- * @type string
- * @default : activate to sort column ascending
- *
- * @dtopt Language
- * @name DataTable.defaults.language.aria.sortDescending
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "aria": {
- * "sortDescending": " - click/return to sort descending"
- * }
- * }
- * } );
- * } );
+ * ARIA label that is added to the table headers when the column is currently being
+ * sorted and next step is to remove sorting
*/
- "sSortDescending": ": activate to sort column descending"
+ "orderableRemove": ": Activate to remove sorting",
+
+ paginate: {
+ first: 'First',
+ last: 'Last',
+ next: 'Next',
+ previous: 'Previous'
+ }
},
/**
* Pagination string used by DataTables for the built-in pagination
* control types.
- * @namespace
- * @name DataTable.defaults.language.paginate
*/
"oPaginate": {
/**
- * Text to use when using the 'full_numbers' type of pagination for the
- * button to take the user to the first page.
- * @type string
- * @default First
- *
- * @dtopt Language
- * @name DataTable.defaults.language.paginate.first
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "paginate": {
- * "first": "First page"
- * }
- * }
- * } );
- * } );
+ * Label and character for first page button
*/
- "sFirst": "First",
-
+ "sFirst": "«",
/**
- * Text to use when using the 'full_numbers' type of pagination for the
- * button to take the user to the last page.
- * @type string
- * @default Last
- *
- * @dtopt Language
- * @name DataTable.defaults.language.paginate.last
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "paginate": {
- * "last": "Last page"
- * }
- * }
- * } );
- * } );
+ * Last page button
*/
- "sLast": "Last",
-
+ "sLast": "»",
/**
- * Text to use for the 'next' pagination button (to take the user to the
- * next page).
- * @type string
- * @default Next
- *
- * @dtopt Language
- * @name DataTable.defaults.language.paginate.next
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "paginate": {
- * "next": "Next page"
- * }
- * }
- * } );
- * } );
+ * Next page button
*/
- "sNext": "Next",
-
+ "sNext": "›",
/**
- * Text to use for the 'previous' pagination button (to take the user to
- * the previous page).
- * @type string
- * @default Previous
- *
- * @dtopt Language
- * @name DataTable.defaults.language.paginate.previous
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "paginate": {
- * "previous": "Previous page"
- * }
- * }
- * } );
- * } );
+ * Previous page button
*/
- "sPrevious": "Previous"
+ "sPrevious": "‹",
+ },
+
+ /**
+ * Plural object for the data type the table is showing
+ */
+ entries: {
+ _: "entries",
+ 1: "entry"
},
/**
@@ -11757,20 +10389,6 @@
* empty of data (regardless of filtering). Note that this is an optional
* parameter - if it is not given, the value of `zeroRecords` will be used
* instead (either the default or given value).
- * @type string
- * @default No data available in table
- *
- * @dtopt Language
- * @name DataTable.defaults.language.emptyTable
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "emptyTable": "No data available in table"
- * }
- * } );
- * } );
*/
"sEmptyTable": "No data available in table",
@@ -11788,66 +10406,23 @@
* * `\_MAX\_` - Number of records in the table without filtering
* * `\_PAGE\_` - Current page number
* * `\_PAGES\_` - Total number of pages of data in the table
- *
- * @type string
- * @default Showing _START_ to _END_ of _TOTAL_ entries
- *
- * @dtopt Language
- * @name DataTable.defaults.language.info
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "info": "Showing page _PAGE_ of _PAGES_"
- * }
- * } );
- * } );
*/
- "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
+ "sInfo": "Showing _START_ to _END_ of _TOTAL_ _ENTRIES-TOTAL_",
/**
* Display information string for when the table is empty. Typically the
* format of this string should match `info`.
- * @type string
- * @default Showing 0 to 0 of 0 entries
- *
- * @dtopt Language
- * @name DataTable.defaults.language.infoEmpty
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "infoEmpty": "No entries to show"
- * }
- * } );
- * } );
*/
- "sInfoEmpty": "Showing 0 to 0 of 0 entries",
+ "sInfoEmpty": "Showing 0 to 0 of 0 _ENTRIES-TOTAL_",
/**
* When a user filters the information in a table, this string is appended
* to the information (`info`) to give an idea of how strong the filtering
* is. The variable _MAX_ is dynamically updated.
- * @type string
- * @default (filtered from _MAX_ total entries)
- *
- * @dtopt Language
- * @name DataTable.defaults.language.infoFiltered
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "infoFiltered": " - filtering from _MAX_ records"
- * }
- * } );
- * } );
*/
- "sInfoFiltered": "(filtered from _MAX_ total entries)",
+ "sInfoFiltered": "(filtered from _MAX_ total _ENTRIES-MAX_)",
/**
@@ -11855,20 +10430,6 @@
* and this variable does exactly that. This information will be appended to
* the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
* being used) at all times.
- * @type string
- * @default Empty string
- *
- * @dtopt Language
- * @name DataTable.defaults.language.infoPostFix
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "infoPostFix": "All records shown are derived from real information."
- * }
- * } );
- * } );
*/
"sInfoPostFix": "",
@@ -11885,21 +10446,6 @@
* the same table and still be sortable, the table must be consistent.
* However, multiple different tables on the page can use different
* decimal place characters.
- * @type string
- * @default
- *
- * @dtopt Language
- * @name DataTable.defaults.language.decimal
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "decimal": ","
- * "thousands": "."
- * }
- * } );
- * } );
*/
"sDecimal": "",
@@ -11909,20 +10455,6 @@
* used to format large numbers that are used in the table information.
* By default a comma is used, but this can be trivially changed to any
* character you wish with this parameter.
- * @type string
- * @default ,
- *
- * @dtopt Language
- * @name DataTable.defaults.language.thousands
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "thousands": "'"
- * }
- * } );
- * } );
*/
"sThousands": ",",
@@ -11932,40 +10464,8 @@
* pagination length option is changed. The '_MENU_' variable is replaced
* with a default select list of 10, 25, 50 and 100, and can be replaced
* with a custom select box if required.
- * @type string
- * @default Show _MENU_ entries
- *
- * @dtopt Language
- * @name DataTable.defaults.language.lengthMenu
- *
- * @example
- * // Language change only
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "lengthMenu": "Display _MENU_ records"
- * }
- * } );
- * } );
- *
- * @example
- * // Language and options change
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "lengthMenu": 'Display records'
- * }
- * } );
- * } );
*/
- "sLengthMenu": "Show _MENU_ entries",
+ "sLengthMenu": "_MENU_ _ENTRIES_ per page",
/**
@@ -11974,20 +10474,6 @@
* indicate to the end user the the data is being loaded. Note that this
* parameter is not used when loading data by server-side processing, just
* Ajax sourced data with client-side processing.
- * @type string
- * @default Loading...
- *
- * @dtopt Language
- * @name DataTable.defaults.language.loadingRecords
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "loadingRecords": "Please wait - loading..."
- * }
- * } );
- * } );
*/
"sLoadingRecords": "Loading...",
@@ -11995,19 +10481,6 @@
/**
* Text which is displayed when the table is processing a user action
* (usually a sort command or similar).
- * @type string
- *
- * @dtopt Language
- * @name DataTable.defaults.language.processing
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "processing": "DataTables is currently busy"
- * }
- * } );
- * } );
*/
"sProcessing": "",
@@ -12018,31 +10491,6 @@
* is replaced with the HTML text box for the filtering input allowing
* control over where it appears in the string. If "_INPUT_" is not given
* then the input box is appended to the string automatically.
- * @type string
- * @default Search:
- *
- * @dtopt Language
- * @name DataTable.defaults.language.search
- *
- * @example
- * // Input text box will be appended at the end automatically
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "search": "Filter records:"
- * }
- * } );
- * } );
- *
- * @example
- * // Specify where the filter should appear
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "search": "Apply filter _INPUT_ to table"
- * }
- * } );
- * } );
*/
"sSearch": "Search:",
@@ -12065,20 +10513,6 @@
* and the object has the same properties as the oLanguage object in the
* initialiser object (i.e. the above parameters). Please refer to one of
* the example language files to see how this works in action.
- * @type string
- * @default Empty string - i.e. disabled
- *
- * @dtopt Language
- * @name DataTable.defaults.language.url
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
- * }
- * } );
- * } );
*/
"sUrl": "",
@@ -12087,20 +10521,6 @@
* Text shown inside the table records when the is no information to be
* displayed after filtering. `emptyTable` is shown when there is simply no
* information in the table at all (regardless of filtering).
- * @type string
- * @default No matching records found
- *
- * @dtopt Language
- * @name DataTable.defaults.language.zeroRecords
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "language": {
- * "zeroRecords": "No records to display"
- * }
- * } );
- * } );
*/
"sZeroRecords": "No matching records found"
},
@@ -12114,132 +10534,31 @@
* (default) it will be treated as a straight string. When `smart`
* DataTables will use it's smart filtering methods (to word match at
* any point in the data), when false this will not be done.
- * @namespace
- * @extends DataTable.models.oSearch
- *
- * @dtopt Options
- * @name DataTable.defaults.search
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "search": {"search": "Initial search"}
- * } );
- * } )
*/
"oSearch": $.extend( {}, DataTable.models.oSearch ),
/**
- * __Deprecated__ The functionality provided by this parameter has now been
- * superseded by that provided through `ajax`, which should be used instead.
- *
- * By default DataTables will look for the property `data` (or `aaData` for
- * compatibility with DataTables 1.9-) when obtaining data from an Ajax
- * source or for server-side processing - this parameter allows that
- * property to be changed. You can use Javascript dotted object notation to
- * get a data source for multiple levels of nesting.
- * @type string
- * @default data
- *
- * @dtopt Options
- * @dtopt Server-side
- * @name DataTable.defaults.ajaxDataProp
- *
- * @deprecated 1.10. Please use `ajax` for this functionality now.
- */
- "sAjaxDataProp": "data",
-
-
- /**
- * __Deprecated__ The functionality provided by this parameter has now been
- * superseded by that provided through `ajax`, which should be used instead.
- *
- * You can instruct DataTables to load data from an external
- * source using this parameter (use aData if you want to pass data in you
- * already have). Simply provide a url a JSON object can be obtained from.
- * @type string
- * @default null
- *
- * @dtopt Options
- * @dtopt Server-side
- * @name DataTable.defaults.ajaxSource
- *
- * @deprecated 1.10. Please use `ajax` for this functionality now.
+ * Table and control layout. This replaces the legacy `dom` option.
*/
- "sAjaxSource": null,
+ layout: {
+ topStart: 'pageLength',
+ topEnd: 'search',
+ bottomStart: 'info',
+ bottomEnd: 'paging'
+ },
/**
- * This initialisation variable allows you to specify exactly where in the
- * DOM you want DataTables to inject the various controls it adds to the page
- * (for example you might want the pagination controls at the top of the
- * table). DIV elements (with or without a custom class) can also be added to
- * aid styling. The follow syntax is used:
- *
- * @type string
- * @default lfrtip (when `jQueryUI` is false)or
- * <"H"lfr>t<"F"ip> (when `jQueryUI` is true)
- *
- * @dtopt Options
- * @name DataTable.defaults.dom
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "dom": '<"top"i>rt<"bottom"flp><"clear">'
- * } );
- * } );
+ * Legacy DOM layout option
*/
- "sDom": "lfrtip",
+ "sDom": null,
/**
* Search delay option. This will throttle full table searches that use the
* DataTables provided search input element (it does not effect calls to
* `dt-api search()`, providing a delay before the search is made.
- * @type integer
- * @default 0
- *
- * @dtopt Options
- * @name DataTable.defaults.searchDelay
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "searchDelay": 200
- * } );
- * } )
*/
"searchDelay": null,
@@ -12254,22 +10573,8 @@
* * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
* * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
* * `first_last_numbers` - 'First' and 'Last' buttons, plus page numbers
- *
- * Further methods can be added using {@link DataTable.ext.oPagination}.
- * @type string
- * @default simple_numbers
- *
- * @dtopt Options
- * @name DataTable.defaults.pagingType
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "pagingType": "full_numbers"
- * } );
- * } )
*/
- "sPaginationType": "simple_numbers",
+ "sPaginationType": "full_numbers",
/**
@@ -12280,19 +10585,6 @@
* scroll horizontally when needed, or any CSS unit, or a number (in which
* case it will be treated as a pixel measurement). Setting as simply `true`
* is recommended.
- * @type boolean|string
- * @default blank string - i.e. disabled
- *
- * @dtopt Features
- * @name DataTable.defaults.scrollX
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "scrollX": true,
- * "scrollCollapse": true
- * } );
- * } );
*/
"sScrollX": "",
@@ -12304,19 +10596,6 @@
* "over-sizing" the table, and thus forcing scrolling. This property can by
* any CSS unit, or a number (in which case it will be treated as a pixel
* measurement).
- * @type string
- * @default blank string - i.e. disabled
- *
- * @dtopt Options
- * @name DataTable.defaults.scrollXInner
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "scrollX": "100%",
- * "scrollXInner": "110%"
- * } );
- * } );
*/
"sScrollXInner": "",
@@ -12328,19 +10607,6 @@
* a lot of data in a small area (although paging and scrolling can both be
* enabled at the same time). This property can be any CSS unit, or a number
* (in which case it will be treated as a pixel measurement).
- * @type string
- * @default blank string - i.e. disabled
- *
- * @dtopt Features
- * @name DataTable.defaults.scrollY
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "scrollY": "200px",
- * "paginate": false
- * } );
- * } );
*/
"sScrollY": "",
@@ -12351,14 +10617,6 @@
*
* Set the HTTP method that is used to make the Ajax call for server-side
* processing or Ajax sourced data.
- * @type string
- * @default GET
- *
- * @dtopt Options
- * @dtopt Server-side
- * @name DataTable.defaults.serverMethod
- *
- * @deprecated 1.10. Please use `ajax` for this functionality now.
*/
"sServerMethod": "GET",
@@ -12372,11 +10630,6 @@
*
* For further information about the renderers available see
* DataTable.ext.renderer
- * @type string|object
- * @default null
- *
- * @name DataTable.defaults.renderer
- *
*/
"renderer": null,
@@ -12384,12 +10637,14 @@
/**
* Set the data property name that DataTables should use to get a row's id
* to set as the `id` property in the node.
- * @type string
- * @default DT_RowId
- *
- * @name DataTable.defaults.rowId
*/
- "rowId": "DT_RowId"
+ "rowId": "DT_RowId",
+
+
+ /**
+ * Caption value
+ */
+ "caption": null
};
_fnHungarianMap( DataTable.defaults );
@@ -12412,176 +10667,35 @@
* doing a sort or use the data from a different column. For example first
* name / last name columns make sense to do a multi-column sort over the
* two columns.
- * @type array|int
- * @default null Takes the value of the column index automatically
- *
- * @name DataTable.defaults.column.orderData
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
- * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
- * { "orderData": 2, "targets": [ 2 ] }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * { "orderData": [ 0, 1 ] },
- * { "orderData": [ 1, 0 ] },
- * { "orderData": 2 },
- * null,
- * null
- * ]
- * } );
- * } );
*/
"aDataSort": null,
"iDataSort": -1,
+ ariaTitle: '',
+
/**
* You can control the default ordering direction, and even alter the
* behaviour of the sort handler (i.e. only allow ascending ordering etc)
* using this parameter.
- * @type array
- * @default [ 'asc', 'desc' ]
- *
- * @name DataTable.defaults.column.orderSequence
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
- * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
- * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * null,
- * { "orderSequence": [ "asc" ] },
- * { "orderSequence": [ "desc", "asc", "asc" ] },
- * { "orderSequence": [ "desc" ] },
- * null
- * ]
- * } );
- * } );
*/
- "asSorting": [ 'asc', 'desc' ],
+ "asSorting": [ 'asc', 'desc', '' ],
/**
- * Enable or disable filtering on the data in this column.
- * @type boolean
- * @default true
- *
- * @name DataTable.defaults.column.searchable
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "searchable": false, "targets": [ 0 ] }
- * ] } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * { "searchable": false },
- * null,
- * null,
- * null,
- * null
- * ] } );
- * } );
+ * Enable or disable filtering on the data in this column.
*/
"bSearchable": true,
/**
* Enable or disable ordering on this column.
- * @type boolean
- * @default true
- *
- * @name DataTable.defaults.column.orderable
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "orderable": false, "targets": [ 0 ] }
- * ] } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * { "orderable": false },
- * null,
- * null,
- * null,
- * null
- * ] } );
- * } );
*/
"bSortable": true,
/**
* Enable or disable the display of this column.
- * @type boolean
- * @default true
- *
- * @name DataTable.defaults.column.visible
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "visible": false, "targets": [ 0 ] }
- * ] } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * { "visible": false },
- * null,
- * null,
- * null,
- * null
- * ] } );
- * } );
*/
"bVisible": true,
@@ -12591,42 +10705,10 @@
* etc) or processed for input (DOM source). This can be used as a compliment to mRender
* allowing you to modify the DOM element (add background colour for example) when the
* element is available.
- * @type function
- * @param {element} td The TD node that has been created
- * @param {*} cellData The Data for the cell
- * @param {array|object} rowData The data for the whole row
- * @param {int} row The row index for the aoData data store
- * @param {int} col The column index for aoColumns
- *
- * @name DataTable.defaults.column.createdCell
- * @dtopt Columns
- *
- * @example
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [ {
- * "targets": [3],
- * "createdCell": function (td, cellData, rowData, row, col) {
- * if ( cellData == "1.7" ) {
- * $(td).css('color', 'blue')
- * }
- * }
- * } ]
- * });
- * } );
*/
"fnCreatedCell": null,
- /**
- * This parameter has been replaced by `data` in DataTables to ensure naming
- * consistency. `dataProp` can still be used, as there is backwards
- * compatibility in DataTables for this option, but it is strongly
- * recommended that you use `data` in preference to `dataProp`.
- * @name DataTable.defaults.column.dataProp
- */
-
-
/**
* This property can be used to read data from any data source property,
* including deeply nested objects / properties. `data` can be given in a
@@ -12688,113 +10770,6 @@
* with the naming of mRender. If 'mDataProp' is given, then it will still
* be used by DataTables, as it automatically maps the old name to the new
* if required.
- *
- * @type string|int|function|null
- * @default null Use automatically calculated column index
- *
- * @name DataTable.defaults.column.data
- * @dtopt Columns
- *
- * @example
- * // Read table data from objects
- * // JSON structure for each row:
- * // {
- * // "engine": {value},
- * // "browser": {value},
- * // "platform": {value},
- * // "version": {value},
- * // "grade": {value}
- * // }
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "ajaxSource": "sources/objects.txt",
- * "columns": [
- * { "data": "engine" },
- * { "data": "browser" },
- * { "data": "platform" },
- * { "data": "version" },
- * { "data": "grade" }
- * ]
- * } );
- * } );
- *
- * @example
- * // Read information from deeply nested objects
- * // JSON structure for each row:
- * // {
- * // "engine": {value},
- * // "browser": {value},
- * // "platform": {
- * // "inner": {value}
- * // },
- * // "details": [
- * // {value}, {value}
- * // ]
- * // }
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "ajaxSource": "sources/deep.txt",
- * "columns": [
- * { "data": "engine" },
- * { "data": "browser" },
- * { "data": "platform.inner" },
- * { "data": "details.0" },
- * { "data": "details.1" }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using `data` as a function to provide different information for
- * // sorting, filtering and display. In this case, currency (price)
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [ {
- * "targets": [ 0 ],
- * "data": function ( source, type, val ) {
- * if (type === 'set') {
- * source.price = val;
- * // Store the computed display and filter values for efficiency
- * source.price_display = val=="" ? "" : "$"+numberFormat(val);
- * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
- * return;
- * }
- * else if (type === 'display') {
- * return source.price_display;
- * }
- * else if (type === 'filter') {
- * return source.price_filter;
- * }
- * // 'sort', 'type' and undefined all just use the integer
- * return source.price;
- * }
- * } ]
- * } );
- * } );
- *
- * @example
- * // Using default content
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [ {
- * "targets": [ 0 ],
- * "data": null,
- * "defaultContent": "Click to edit"
- * } ]
- * } );
- * } );
- *
- * @example
- * // Using array notation - outputting a list from an array
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [ {
- * "targets": [ 0 ],
- * "data": "name[, ]"
- * } ]
- * } );
- * } );
- *
*/
"mData": null,
@@ -12848,75 +10823,6 @@
* * Return:
* * The return value from the function is what will be used for the
* data requested.
- *
- * @type string|int|function|object|null
- * @default null Use the data source value.
- *
- * @name DataTable.defaults.column.render
- * @dtopt Columns
- *
- * @example
- * // Create a comma separated list from an array of objects
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "ajaxSource": "sources/deep.txt",
- * "columns": [
- * { "data": "engine" },
- * { "data": "browser" },
- * {
- * "data": "platform",
- * "render": "[, ].name"
- * }
- * ]
- * } );
- * } );
- *
- * @example
- * // Execute a function to obtain data
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [ {
- * "targets": [ 0 ],
- * "data": null, // Use the full data source object for the renderer's source
- * "render": "browserName()"
- * } ]
- * } );
- * } );
- *
- * @example
- * // As an object, extracting different data for the different types
- * // This would be used with a data source such as:
- * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
- * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
- * // (which has both forms) is used for filtering for if a user inputs either format, while
- * // the formatted phone number is the one that is shown in the table.
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [ {
- * "targets": [ 0 ],
- * "data": null, // Use the full data source object for the renderer's source
- * "render": {
- * "_": "phone",
- * "filter": "phone_filter",
- * "display": "phone_display"
- * }
- * } ]
- * } );
- * } );
- *
- * @example
- * // Use as a function to create a link from the data source
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [ {
- * "targets": [ 0 ],
- * "data": "download_link",
- * "render": function ( data, type, full ) {
- * return 'Download';
- * }
- * } ]
- * } );
- * } );
*/
"mRender": null,
@@ -12925,57 +10831,12 @@
* Change the cell type created for the column - either TD cells or TH cells. This
* can be useful as TH cells have semantic meaning in the table body, allowing them
* to act as a header for a row (you may wish to add scope='row' to the TH elements).
- * @type string
- * @default td
- *
- * @name DataTable.defaults.column.cellType
- * @dtopt Columns
- *
- * @example
- * // Make the first column use TH cells
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [ {
- * "targets": [ 0 ],
- * "cellType": "th"
- * } ]
- * } );
- * } );
*/
"sCellType": "td",
/**
* Class to give to each cell in this column.
- * @type string
- * @default Empty string
- *
- * @name DataTable.defaults.column.class
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "class": "my_class", "targets": [ 0 ] }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * { "class": "my_class" },
- * null,
- * null,
- * null,
- * null
- * ]
- * } );
- * } );
*/
"sClass": "",
@@ -12989,26 +10850,6 @@
* a "work around" we provide this option. It will append its value to the
* text that is found to be the longest string for the column - i.e. padding.
* Generally you shouldn't need this!
- * @type string
- * @default Empty string
- *
- * @name DataTable.defaults.column.contentPadding
- * @dtopt Columns
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * null,
- * null,
- * null,
- * {
- * "contentPadding": "mmm"
- * }
- * ]
- * } );
- * } );
*/
"sContentPadding": "",
@@ -13017,41 +10858,6 @@
* Allows a default value to be given for a column's data, and will be used
* whenever a null data source is encountered (this can be because `data`
* is set to null, or because the data source itself is null).
- * @type string
- * @default null
- *
- * @name DataTable.defaults.column.defaultContent
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * {
- * "data": null,
- * "defaultContent": "Edit",
- * "targets": [ -1 ]
- * }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * null,
- * null,
- * null,
- * {
- * "data": null,
- * "defaultContent": "Edit"
- * }
- * ]
- * } );
- * } );
*/
"sDefaultContent": null,
@@ -13063,39 +10869,6 @@
* also allow DataTables to reorder information from the server if it comes
* back in an unexpected order (i.e. if you switch your columns around on the
* client-side, your server-side code does not also need updating).
- * @type string
- * @default Empty string
- *
- * @name DataTable.defaults.column.name
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "name": "engine", "targets": [ 0 ] },
- * { "name": "browser", "targets": [ 1 ] },
- * { "name": "platform", "targets": [ 2 ] },
- * { "name": "version", "targets": [ 3 ] },
- * { "name": "grade", "targets": [ 4 ] }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * { "name": "engine" },
- * { "name": "browser" },
- * { "name": "platform" },
- * { "name": "version" },
- * { "name": "grade" }
- * ]
- * } );
- * } );
*/
"sName": "",
@@ -13105,75 +10878,12 @@
* real-time information from the table (updating the internally cached
* version) prior to ordering. This allows ordering to occur on user
* editable elements such as form inputs.
- * @type string
- * @default std
- *
- * @name DataTable.defaults.column.orderDataType
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
- * { "type": "numeric", "targets": [ 3 ] },
- * { "orderDataType": "dom-select", "targets": [ 4 ] },
- * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * null,
- * null,
- * { "orderDataType": "dom-text" },
- * { "orderDataType": "dom-text", "type": "numeric" },
- * { "orderDataType": "dom-select" },
- * { "orderDataType": "dom-checkbox" }
- * ]
- * } );
- * } );
*/
"sSortDataType": "std",
/**
* The title of this column.
- * @type string
- * @default null Derived from the 'TH' value for this column in the
- * original HTML table.
- *
- * @name DataTable.defaults.column.title
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "title": "My column title", "targets": [ 0 ] }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * { "title": "My column title" },
- * null,
- * null,
- * null,
- * null
- * ]
- * } );
- * } );
*/
"sTitle": null,
@@ -13186,35 +10896,6 @@
* date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
* 'numeric', 'date' or 'html' (by default). Further types can be adding
* through plug-ins.
- * @type string
- * @default null Auto-detected from raw data
- *
- * @name DataTable.defaults.column.type
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "type": "html", "targets": [ 0 ] }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * { "type": "html" },
- * null,
- * null,
- * null,
- * null
- * ]
- * } );
- * } );
*/
"sType": null,
@@ -13224,35 +10905,6 @@
* (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
* been given a specific width through this interface ensuring that the table
* remains readable.
- * @type string
- * @default null Automatic
- *
- * @name DataTable.defaults.column.width
- * @dtopt Columns
- *
- * @example
- * // Using `columnDefs`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columnDefs": [
- * { "width": "20%", "targets": [ 0 ] }
- * ]
- * } );
- * } );
- *
- * @example
- * // Using `columns`
- * $(document).ready( function() {
- * $('#example').dataTable( {
- * "columns": [
- * { "width": "20%" },
- * null,
- * null,
- * null,
- * null
- * ]
- * } );
- * } );
*/
"sWidth": null
};
@@ -13274,19 +10926,10 @@
* one is the internal data store for DataTables's cache of columns. It should
* NOT be manipulated outside of DataTables. Any configuration should be done
* through the initialisation options.
- * @namespace
- * @todo Really should attach the settings object to individual instances so we
- * don't need to create new instances on each $().dataTable() call (if the
- * table already exists). It would also save passing oSettings around and
- * into every single function. However, this is a very significant
- * architecture change for DataTables and will almost certainly break
- * backwards compatibility with older installations. This is something that
- * will be done in 2.0.
*/
DataTable.models.oSettings = {
/**
* Primary features of DataTables and their enablement state.
- * @namespace
*/
"oFeatures": {
@@ -13295,7 +10938,6 @@
* optimum table and columns widths (true) or not (false).
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bAutoWidth": null,
@@ -13306,7 +10948,6 @@
* difference at all for DOM and server-side processing tables.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bDeferRender": null,
@@ -13316,34 +10957,26 @@
* To just remove the filtering input use sDom and remove the 'f' option.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bFilter": null,
/**
- * Table information element (the 'Showing x of y records' div) enable
- * flag.
- * Note that this parameter will be set by the initialisation routine. To
- * set a default use {@link DataTable.defaults}.
- * @type boolean
+ * Used only for compatiblity with DT1
+ * @deprecated
*/
- "bInfo": null,
+ "bInfo": true,
/**
- * Present a user control allowing the end user to change the page size
- * when pagination is enabled.
- * Note that this parameter will be set by the initialisation routine. To
- * set a default use {@link DataTable.defaults}.
- * @type boolean
+ * Used only for compatiblity with DT1
+ * @deprecated
*/
- "bLengthChange": null,
+ "bLengthChange": true,
/**
* Pagination enabled or not. Note that if this is disabled then length
* changing must also be disabled.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bPaginate": null,
@@ -13352,7 +10985,6 @@
* user request - typically an Ajax request for server-side processing.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bProcessing": null,
@@ -13362,7 +10994,6 @@
* sorting or paging done on the client-side.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bServerSide": null,
@@ -13370,7 +11001,6 @@
* Sorting enablement flag.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bSort": null,
@@ -13378,7 +11008,6 @@
* Multi-column sorting
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bSortMulti": null,
@@ -13388,7 +11017,6 @@
* there is a lot of DOM interaction.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bSortClasses": null,
@@ -13396,7 +11024,6 @@
* State saving enablement flag.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bStateSave": null
},
@@ -13404,7 +11031,6 @@
/**
* Scrolling settings for a table.
- * @namespace
*/
"oScroll": {
/**
@@ -13412,15 +11038,12 @@
* table container down to the height of the table (when true).
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bCollapse": null,
/**
* Width of the scrollbar for the web-browser's platform. Calculated
* during table initialisation.
- * @type int
- * @default 0
*/
"iBarWidth": 0,
@@ -13429,7 +11052,6 @@
* disabled if an empty string.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type string
*/
"sX": null,
@@ -13438,7 +11060,6 @@
* should not need to use this.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type string
* @deprecated
*/
"sXInner": null,
@@ -13448,59 +11069,34 @@
* if an empty string.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type string
*/
"sY": null
},
/**
* Language information for the table.
- * @namespace
- * @extends DataTable.defaults.oLanguage
*/
"oLanguage": {
/**
* Information callback function. See
* {@link DataTable.defaults.fnInfoCallback}
- * @type function
- * @default null
*/
"fnInfoCallback": null
},
/**
* Browser support parameters
- * @namespace
*/
"oBrowser": {
- /**
- * Indicate if the browser incorrectly calculates width:100% inside a
- * scrolling element (IE6/7)
- * @type boolean
- * @default false
- */
- "bScrollOversize": false,
-
/**
* Determine if the vertical scrollbar is on the right or left of the
* scrolling container - needed for rtl language layout, although not
* all browsers move the scrollbar (Safari).
- * @type boolean
- * @default false
*/
"bScrollbarLeft": false,
- /**
- * Flag for if `getBoundingClientRect` is fully supported or not
- * @type boolean
- * @default false
- */
- "bBounding": false,
-
/**
* Browser scrollbar width
- * @type integer
- * @default 0
*/
"barWidth": 0
},
@@ -13520,58 +11116,42 @@
*
'p' - Pagination
*
'r' - pRocessing
*
- * @type array
- * @default []
*/
"aanFeatures": [],
/**
* Store data information - see {@link DataTable.models.oRow} for detailed
* information.
- * @type array
- * @default []
*/
"aoData": [],
/**
* Array of indexes which are in the current display (after filtering etc)
- * @type array
- * @default []
*/
"aiDisplay": [],
/**
* Array of indexes for display - no filtering
- * @type array
- * @default []
*/
"aiDisplayMaster": [],
/**
* Map of row ids to data indexes
- * @type object
- * @default {}
*/
"aIds": {},
/**
* Store information about each column that is in use
- * @type array
- * @default []
*/
"aoColumns": [],
/**
* Store information about the table's header
- * @type array
- * @default []
*/
"aoHeader": [],
/**
* Store information about the table's footer
- * @type array
- * @default []
*/
"aoFooter": [],
@@ -13580,17 +11160,18 @@
* research or compare the old search to a new one.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @namespace
- * @extends DataTable.models.oSearch
*/
"oPreviousSearch": {},
+ /**
+ * Store for named searches
+ */
+ searchFixed: {},
+
/**
* Store the applied search for each column - see
* {@link DataTable.models.oSearch} for the format that is used for the
* filtering information for each column.
- * @type array
- * @default []
*/
"aoPreSearchCols": [],
@@ -13603,8 +11184,6 @@
*
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type array
- * @todo These inner arrays should really be objects
*/
"aaSorting": null,
@@ -13613,81 +11192,47 @@
* aaSorting).
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type array
- * @default []
*/
"aaSortingFixed": [],
- /**
- * Classes to use for the striping of a table.
- * Note that this parameter will be set by the initialisation routine. To
- * set a default use {@link DataTable.defaults}.
- * @type array
- * @default []
- */
- "asStripeClasses": null,
-
- /**
- * If restoring a table - we should restore its striping classes as well
- * @type array
- * @default []
- */
- "asDestroyStripes": [],
-
/**
* If restoring a table - we should restore its width
- * @type int
- * @default 0
*/
"sDestroyWidth": 0,
/**
* Callback functions array for every time a row is inserted (i.e. on a draw).
- * @type array
- * @default []
*/
"aoRowCallback": [],
/**
* Callback functions for the header on each draw.
- * @type array
- * @default []
*/
"aoHeaderCallback": [],
/**
* Callback function for the footer on each draw.
- * @type array
- * @default []
*/
"aoFooterCallback": [],
/**
* Array of callback functions for draw callback functions
- * @type array
- * @default []
*/
"aoDrawCallback": [],
/**
* Array of callback functions for row created function
- * @type array
- * @default []
*/
"aoRowCreatedCallback": [],
/**
* Callback functions for just before the table is redrawn. A return of
* false will be used to cancel the draw.
- * @type array
- * @default []
*/
"aoPreDrawCallback": [],
/**
* Callback functions for when the table has been initialised.
- * @type array
- * @default []
*/
"aoInitComplete": [],
@@ -13695,91 +11240,59 @@
/**
* Callbacks for modifying the settings to be stored for state saving, prior to
* saving state.
- * @type array
- * @default []
*/
"aoStateSaveParams": [],
/**
* Callbacks for modifying the settings that have been stored for state saving
* prior to using the stored values to restore the state.
- * @type array
- * @default []
*/
"aoStateLoadParams": [],
/**
* Callbacks for operating on the settings object once the saved state has been
* loaded
- * @type array
- * @default []
*/
"aoStateLoaded": [],
/**
* Cache the table ID for quick access
- * @type string
- * @default Empty string
*/
"sTableId": "",
/**
* The TABLE node for the main table
- * @type node
- * @default null
*/
"nTable": null,
/**
* Permanent ref to the thead element
- * @type node
- * @default null
*/
"nTHead": null,
/**
* Permanent ref to the tfoot element - if it exists
- * @type node
- * @default null
*/
"nTFoot": null,
/**
* Permanent ref to the tbody element
- * @type node
- * @default null
*/
"nTBody": null,
/**
* Cache the wrapper node (contains all DataTables controlled elements)
- * @type node
- * @default null
*/
"nTableWrapper": null,
- /**
- * Indicate if when using server-side processing the loading of data
- * should be deferred until the second draw.
- * Note that this parameter will be set by the initialisation routine. To
- * set a default use {@link DataTable.defaults}.
- * @type boolean
- * @default false
- */
- "bDeferLoading": false,
-
/**
* Indicate if all required information has been read in
- * @type boolean
- * @default false
*/
"bInitialised": false,
/**
* Information about open rows. Each object in the array has the parameters
* 'nTr' and 'nParent'
- * @type array
- * @default []
*/
"aoOpenRows": [],
@@ -13788,15 +11301,11 @@
* {@link DataTable.model.oInit.sDom}.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type string
- * @default null
*/
"sDom": null,
/**
* Search delay (in mS)
- * @type integer
- * @default null
*/
"searchDelay": null,
@@ -13804,17 +11313,18 @@
* Which type of pagination should be used.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type string
- * @default two_button
*/
"sPaginationType": "two_button",
+ /**
+ * Number of paging controls on the page. Only used for backwards compatibility
+ */
+ pagingControls: 0,
+
/**
* The state duration (for `stateSave`) in seconds.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type int
- * @default 0
*/
"iStateDuration": 0,
@@ -13828,8 +11338,6 @@
* (i.e. '"param": [ 0, 1, 2]')
*
string:sName - name of callback
*
- * @type array
- * @default []
*/
"aoStateSave": [],
@@ -13841,89 +11349,46 @@
* and the object stored. May return false to cancel state loading
*
string:sName - name of callback
*
- * @type array
- * @default []
*/
"aoStateLoad": [],
/**
* State that was saved. Useful for back reference
- * @type object
- * @default null
*/
"oSavedState": null,
/**
* State that was loaded. Useful for back reference
- * @type object
- * @default null
*/
"oLoadedState": null,
/**
- * Source url for AJAX data for the table.
- * Note that this parameter will be set by the initialisation routine. To
- * set a default use {@link DataTable.defaults}.
- * @type string
- * @default null
- */
- "sAjaxSource": null,
-
- /**
- * Property from a given object from which to read the table data from. This
- * can be an empty string (when not server-side processing), in which case
- * it is assumed an an array is given directly.
- * Note that this parameter will be set by the initialisation routine. To
- * set a default use {@link DataTable.defaults}.
- * @type string
+ * Note if draw should be blocked while getting data
*/
- "sAjaxDataProp": null,
+ "bAjaxDataGet": true,
/**
* The last jQuery XHR object that was used for server-side data gathering.
* This can be used for working with the XHR information in one of the
* callbacks
- * @type object
- * @default null
*/
"jqXHR": null,
/**
* JSON returned from the server in the last Ajax request
- * @type object
- * @default undefined
*/
"json": undefined,
/**
* Data submitted as part of the last Ajax request
- * @type object
- * @default undefined
*/
"oAjaxData": undefined,
- /**
- * Function to get the server-side data.
- * Note that this parameter will be set by the initialisation routine. To
- * set a default use {@link DataTable.defaults}.
- * @type function
- */
- "fnServerData": null,
-
- /**
- * Functions which are called prior to sending an Ajax request so extra
- * parameters can easily be sent to the server
- * @type array
- * @default []
- */
- "aoServerParams": [],
-
/**
* Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
* required).
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type string
*/
"sServerMethod": null,
@@ -13931,7 +11396,6 @@
* Format numbers for display.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type function
*/
"fnFormatNumber": null,
@@ -13939,44 +11403,32 @@
* List of options that can be used for the user selectable length menu.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type array
- * @default []
*/
"aLengthMenu": null,
/**
* Counter for the draws that the table does. Also used as a tracker for
* server-side processing
- * @type int
- * @default 0
*/
"iDraw": 0,
/**
* Indicate if a redraw is being done - useful for Ajax
- * @type boolean
- * @default false
*/
"bDrawing": false,
/**
* Draw index (iDraw) of the last error when parsing the returned data
- * @type int
- * @default -1
*/
"iDrawError": -1,
/**
* Paging display length
- * @type int
- * @default 10
*/
"_iDisplayLength": 10,
/**
* Paging start point - aiDisplay index
- * @type int
- * @default 0
*/
"_iDisplayStart": 0,
@@ -13985,9 +11437,6 @@
* (i.e. before filtering), Use fnRecordsTotal rather than
* this property to get the value of the number of records, regardless of
* the server-side processing setting.
- * @type int
- * @default 0
- * @private
*/
"_iRecordsTotal": 0,
@@ -13996,16 +11445,11 @@
* (i.e. after filtering). Use fnRecordsDisplay rather than
* this property to get the value of the number of records, regardless of
* the server-side processing setting.
- * @type boolean
- * @default 0
- * @private
*/
"_iRecordsDisplay": 0,
/**
* The classes to use for the table
- * @type object
- * @default {}
*/
"oClasses": {},
@@ -14013,8 +11457,6 @@
* Flag attached to the settings object so you can check in the draw
* callback if filtering has been done in the draw. Deprecated in favour of
* events.
- * @type boolean
- * @default false
* @deprecated
*/
"bFiltered": false,
@@ -14023,8 +11465,6 @@
* Flag attached to the settings object so you can check in the draw
* callback if sorting has been done in the draw. Deprecated in favour of
* events.
- * @type boolean
- * @default false
* @deprecated
*/
"bSorted": false,
@@ -14035,29 +11475,23 @@
* should be used for sorting / title by DataTables.
* Note that this parameter will be set by the initialisation routine. To
* set a default use {@link DataTable.defaults}.
- * @type boolean
*/
"bSortCellsTop": null,
/**
* Initialisation object that is used for the table
- * @type object
- * @default null
*/
"oInit": null,
/**
* Destroy callback functions - for plug-ins to attach themselves to the
* destroy so they can clean up markup and events.
- * @type array
- * @default []
*/
"aoDestroyCallback": [],
/**
* Get the number of records in the current record set, before filtering
- * @type function
*/
"fnRecordsTotal": function ()
{
@@ -14068,7 +11502,6 @@
/**
* Get the number of records in the current record set, after filtering
- * @type function
*/
"fnRecordsDisplay": function ()
{
@@ -14079,7 +11512,6 @@
/**
* Get the display end point - aiDisplay index
- * @type function
*/
"fnDisplayEnd": function ()
{
@@ -14105,8 +11537,6 @@
/**
* The DataTables object for this table
- * @type object
- * @default null
*/
"oInstance": null,
@@ -14114,8 +11544,6 @@
* Unique identifier for each instance of the DataTables object. If there
* is an ID on the table node, then it takes that value, otherwise an
* incrementing internal counter is used.
- * @type string
- * @default null
*/
"sInstance": null,
@@ -14137,31 +11565,29 @@
/**
* Last applied sort
- * @type array
- * @default []
*/
"aLastSort": [],
/**
* Stored plug-in instances
- * @type object
- * @default {}
*/
"oPlugins": {},
/**
* Function used to get a row's id from the row's data
- * @type function
- * @default null
*/
"rowIdFn": null,
/**
* Data location where to store a row's id
- * @type string
- * @default null
*/
- "rowId": null
+ "rowId": null,
+
+ caption: '',
+
+ captionNode: null,
+
+ colgroup: null
};
/**
@@ -14215,7 +11641,7 @@
*
* @type string
*/
- build:"bs5/dt-1.13.6",
+ build:"bs5/dt-2.0.0",
/**
@@ -14230,44 +11656,18 @@
errMode: "alert",
+ /**
+ * Legacy so v1 plug-ins don't throw js errors on load
+ */
+ feature: [],
+
/**
* Feature plug-ins.
*
- * This is an array of objects which describe the feature plug-ins that are
- * available to DataTables. These feature plug-ins are then available for
- * use through the `dom` initialisation option.
- *
- * Each feature plug-in is described by an object which must have the
- * following properties:
- *
- * * `fnInit` - function that is used to initialise the plug-in,
- * * `cFeature` - a character so the feature can be enabled by the `dom`
- * instillation option. This is case sensitive.
- *
- * The `fnInit` function has the following input parameters:
- *
- * 1. `{object}` DataTables settings object: see
- * {@link DataTable.models.oSettings}
- *
- * And the following return is expected:
- *
- * * {node|null} The element which contains your feature. Note that the
- * return may also be void if your plug-in does not require to inject any
- * DOM elements into DataTables control (`dom`) - for example this might
- * be useful when developing a plug-in which allows table control via
- * keyboard entry
- *
- * @type array
- *
- * @example
- * $.fn.dataTable.ext.features.push( {
- * "fnInit": function( oSettings ) {
- * return new TableTools( { "oDTSettings": oSettings } );
- * },
- * "cFeature": "T"
- * } );
+ * This is an object of callbacks which provide the features for DataTables
+ * to be initialised via the `layout` option.
*/
- feature: [],
+ features: {},
/**
@@ -14362,19 +11762,6 @@
},
- /**
- * Internal functions, exposed for used in plug-ins.
- *
- * Please note that you should not need to use the internal methods for
- * anything other than a plug-in (and even then, try to avoid if possible).
- * The internal function may change between releases.
- *
- * @type object
- * @default {}
- */
- internal: {},
-
-
/**
* Legacy configuration options. Enable and disable legacy options that
* are available in DataTables.
@@ -14501,6 +11888,11 @@
* @namespace
*/
type: {
+ /**
+ * Automatic column class assignment
+ */
+ className: {},
+
/**
* Type detection functions.
*
@@ -14543,6 +11935,11 @@
*/
detect: [],
+ /**
+ * Automatic renderer assignment
+ */
+ render: {},
+
/**
* Type based search formatting.
@@ -14682,14 +12079,6 @@
iApiIndex: 0,
- /**
- * jQuery UI class container
- * @type object
- * @deprecated Since v1.10
- */
- oJUIClasses: {},
-
-
/**
* Software version
* @type string
@@ -14709,286 +12098,641 @@
oSort: _ext.type.order,
afnSortData: _ext.order,
aoFeatures: _ext.feature,
- oApi: _ext.internal,
oStdClasses: _ext.classes,
oPagination: _ext.pager
} );
$.extend( DataTable.ext.classes, {
- "sTable": "dataTable",
- "sNoFooter": "no-footer",
-
- /* Paging buttons */
- "sPageButton": "paginate_button",
- "sPageButtonActive": "current",
- "sPageButtonDisabled": "disabled",
-
- /* Striping classes */
- "sStripeOdd": "odd",
- "sStripeEven": "even",
-
- /* Empty row */
- "sRowEmpty": "dataTables_empty",
-
- /* Features */
- "sWrapper": "dataTables_wrapper",
- "sFilter": "dataTables_filter",
- "sInfo": "dataTables_info",
- "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
- "sLength": "dataTables_length",
- "sProcessing": "dataTables_processing",
-
- /* Sorting */
- "sSortAsc": "sorting_asc",
- "sSortDesc": "sorting_desc",
- "sSortable": "sorting", /* Sortable in both directions */
- "sSortableAsc": "sorting_desc_disabled",
- "sSortableDesc": "sorting_asc_disabled",
- "sSortableNone": "sorting_disabled",
- "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
-
- /* Filtering */
- "sFilterInput": "",
-
- /* Page length */
- "sLengthSelect": "",
-
- /* Scrolling */
- "sScrollWrapper": "dataTables_scroll",
- "sScrollHead": "dataTables_scrollHead",
- "sScrollHeadInner": "dataTables_scrollHeadInner",
- "sScrollBody": "dataTables_scrollBody",
- "sScrollFoot": "dataTables_scrollFoot",
- "sScrollFootInner": "dataTables_scrollFootInner",
-
- /* Misc */
- "sHeaderTH": "",
- "sFooterTH": "",
-
- // Deprecated
- "sSortJUIAsc": "",
- "sSortJUIDesc": "",
- "sSortJUI": "",
- "sSortJUIAscAllowed": "",
- "sSortJUIDescAllowed": "",
- "sSortJUIWrapper": "",
- "sSortIcon": "",
- "sJUIHeader": "",
- "sJUIFooter": ""
+ container: 'dt-container',
+ empty: {
+ row: 'dt-empty'
+ },
+ info: {
+ container: 'dt-info'
+ },
+ length: {
+ container: 'dt-length',
+ select: 'dt-input'
+ },
+ order: {
+ canAsc: 'dt-orderable-asc',
+ canDesc: 'dt-orderable-desc',
+ isAsc: 'dt-ordering-asc',
+ isDesc: 'dt-ordering-desc',
+ none: 'dt-orderable-none',
+ position: 'sorting_'
+ },
+ processing: {
+ container: 'dt-processing'
+ },
+ scrolling: {
+ body: 'dt-scroll-body',
+ container: 'dt-scroll',
+ footer: {
+ self: 'dt-scroll-foot',
+ inner: 'dt-scroll-footInner'
+ },
+ header: {
+ self: 'dt-scroll-head',
+ inner: 'dt-scroll-headInner'
+ }
+ },
+ search: {
+ container: 'dt-search',
+ input: 'dt-input'
+ },
+ table: 'dataTable',
+ tbody: {
+ cell: '',
+ row: ''
+ },
+ thead: {
+ cell: '',
+ row: ''
+ },
+ tfoot: {
+ cell: '',
+ row: ''
+ },
+ paging: {
+ active: 'current',
+ button: 'dt-paging-button',
+ container: 'dt-paging',
+ disabled: 'disabled'
+ }
+ } );
+
+
+ var extPagination = DataTable.ext.pager;
+
+ // Paging buttons configuration
+ $.extend( extPagination, {
+ simple: function () {
+ return [ 'previous', 'next' ];
+ },
+
+ full: function () {
+ return [ 'first', 'previous', 'next', 'last' ];
+ },
+
+ numbers: function () {
+ return [ 'numbers' ];
+ },
+
+ simple_numbers: function () {
+ return [ 'previous', 'numbers', 'next' ];
+ },
+
+ full_numbers: function () {
+ return [ 'first', 'previous', 'numbers', 'next', 'last' ];
+ },
+
+ first_last: function () {
+ return ['first', 'last'];
+ },
+
+ first_last_numbers: function () {
+ return ['first', 'numbers', 'last'];
+ },
+
+ // For testing and plug-ins to use
+ _numbers: _pagingNumbers,
+
+ // Number of number buttons - legacy, use `numbers` option for paging feature
+ numbers_length: 7
} );
- var extPagination = DataTable.ext.pager;
+ $.extend( true, DataTable.ext.renderer, {
+ pagingButton: {
+ _: function (settings, buttonType, content, active, disabled) {
+ var classes = settings.oClasses.paging;
+ var btnClasses = [classes.button];
+ var btn;
+
+ if (active) {
+ btnClasses.push(classes.active);
+ }
+
+ if (disabled) {
+ btnClasses.push(classes.disabled)
+ }
+
+ if (buttonType === 'ellipsis') {
+ btn = $('').html(content)[0];
+ }
+ else {
+ btn = $('