Fix a number of errors such as leaking variables and code stylepull/40/head
parent
4f29d7fda6
commit
4df671ed24
@ -1,19 +1,33 @@
|
||||
/**
|
||||
* When DataTables removes columns from the display (bVisible or
|
||||
* fnSetColumnVis) it removes these elements from the DOM, effecting the
|
||||
* index value for the column positions. This function converts the data
|
||||
* column index (i.e. all columns regardless of visibility) into a visible
|
||||
* column index.
|
||||
* When DataTables removes columns from the display (`bVisible` or
|
||||
* `fnSetColumnVis`) it removes these elements from the DOM, effecting the index
|
||||
* value for the column positions. This function converts the data column index
|
||||
* (i.e. all columns regardless of visibility) into a visible column index.
|
||||
*
|
||||
* DataTables 1.10+ has this ability built-in through the
|
||||
* `dt-api column.index()` method. As such this method is marked deprecated, but
|
||||
* is available for use with legacy version of DataTables.
|
||||
*
|
||||
* @name fnColumnIndexToVisible
|
||||
* @summary
|
||||
* @summary Convert a column data index to a visible index.
|
||||
* @author [Allan Jardine](http://sprymedia.co.uk)
|
||||
* @deprecated
|
||||
*
|
||||
* @param {integer} iMatch Column data index to convert to visible index
|
||||
* @returns {integer} Visible column index
|
||||
*
|
||||
* @example
|
||||
* var table = $('#example').dataTable( {
|
||||
* aoColumnDefs: [
|
||||
* { bVisible: false, aTargets: [1] }
|
||||
* ]
|
||||
* } );
|
||||
*
|
||||
* // This will show 1
|
||||
* alert( 'Column 2 visible index: '+table.fnColumnIndexToVisible(2) );
|
||||
*/
|
||||
|
||||
$.fn.dataTableExt.oApi.fnColumnIndexToVisible = function ( oSettings, iMatch )
|
||||
jQuery.fn.dataTableExt.oApi.fnColumnIndexToVisible = function ( oSettings, iMatch )
|
||||
{
|
||||
return oSettings.oApi._fnColumnIndexToVisible( oSettings, iMatch );
|
||||
};
|
||||
|
@ -1,20 +1,38 @@
|
||||
/**
|
||||
* Jump to data
|
||||
* It can be quite useful to jump straight to a page which contains a certain
|
||||
* piece of data (a user name for example). This plug-in provides exactly that
|
||||
* ability, searching for a given data parameter from a given column and
|
||||
* immediately shifting the paging of the table to jump to that point.
|
||||
*
|
||||
* If multiple data points match the requested data, the paging will be shifted
|
||||
* to show the first instance. If there are no matches, the paging will not
|
||||
* change.
|
||||
*
|
||||
* Note that unlike the core DataTables API methods, this plug-in will
|
||||
* automatically call `dt-api draw()` to redraw the table with the current page
|
||||
* shown.
|
||||
*
|
||||
* @name page.JumpToData()
|
||||
* @summary
|
||||
* @summary Jump to a page by searching for data from a column
|
||||
* @author [Allan Jardine](http://sprymedia.co.uk)
|
||||
* @requires DataTables 1.10+
|
||||
*
|
||||
* @param {*} data Data to search for
|
||||
* @param {integer} column Column index
|
||||
* @returns {Api} DataTables API instance
|
||||
*
|
||||
* @example
|
||||
* var table = $('#example').DataTable();
|
||||
* table.page.jumpToData( 0, "Allan Jardine" );
|
||||
*/
|
||||
|
||||
jQuery.fn.dataTable.Api.register( 'page.jumpToData()', function ( column, data ) {
|
||||
jQuery.fn.dataTable.Api.register( 'page.jumpToData()', function ( data, column ) {
|
||||
var pos = this.column(column, {order:'current'}).data().indexOf( data );
|
||||
|
||||
if ( pos >= 0 ) {
|
||||
var page = Math.floor( pos / this.page.info().length );
|
||||
this.page( page ).draw( false );
|
||||
}
|
||||
|
||||
return this;
|
||||
} );
|
Loading…
Reference in new issue