From d7058eb45d5d71afade747107cbe58fa32843b05 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Mon, 29 Apr 2013 07:51:41 +0100 Subject: [PATCH] New: search() and columns().search() API methods - Ability to filter the table through the new API. - This effectively replaces the fnFilter method of the old API. - Note that one capability which has been removed from the old API is the ability to not show the new filter on the filtering input elements. I can't see any use for that feature to be honest, so it has been dropped. The filtering inputs always show the global filter state now. - Additionally, note that we've been forced to call this `search` here rather than `filter` since there is a `filter` method for the API collection instance. This might be revisted before release. --- media/src/DataTables.js | 3 ++- media/src/api/api.columns.js | 4 +++- media/src/api/api.core.js | 6 +++--- media/src/core/core.data.js | 4 ++-- media/src/core/core.filter.js | 12 ++++++------ media/src/core/core.length.js | 23 ++--------------------- media/src/core/core.support.js | 21 +++++++++++++++++++++ 7 files changed, 39 insertions(+), 34 deletions(-) diff --git a/media/src/DataTables.js b/media/src/DataTables.js index a9b89d41..5897f0a4 100644 --- a/media/src/DataTables.js +++ b/media/src/DataTables.js @@ -99,7 +99,7 @@ { require('api.methods.js'); require('api.internal.js'); - + var _that = this; this.each(function() { require('core.constructor.js'); @@ -117,6 +117,7 @@ require('api._selectors.js'); require('api.rows.js'); require('api.columns.js'); + require('api.search.js'); require('api.static.js'); /** diff --git a/media/src/api/api.columns.js b/media/src/api/api.columns.js index 76db6423..43e5c3cd 100644 --- a/media/src/api/api.columns.js +++ b/media/src/api/api.columns.js @@ -135,12 +135,14 @@ _api.register( 'columns().visible()', function ( vis ) { // } ); + _api.register( 'columns.adjust()', function () { - this.iterator( 'table', function ( settings ) { + return this.iterator( 'table', function ( settings ) { _fnAdjustColumnSizing( settings ); } ); } ); + // Convert from one column index type, to another type _api.register( 'column.index()', function ( type, idx ) { if ( this.context.length !== 0 ) { diff --git a/media/src/api/api.core.js b/media/src/api/api.core.js index 12744810..10cc2fa2 100644 --- a/media/src/api/api.core.js +++ b/media/src/api/api.core.js @@ -283,7 +283,7 @@ _Api.prototype = /** @lends DataTables.Api */{ fn.call( this, this[i], i, this ); } } - + return this; }, @@ -336,7 +336,7 @@ _Api.prototype = /** @lends DataTables.Api */{ for ( i=0, ien=context.length ; i') : sSearchStr==="" ? '' : sSearchStr+' '; - + var nFilter = document.createElement( 'div' ); nFilter.className = oSettings.oClasses.sFilter; nFilter.innerHTML = ''; @@ -21,7 +21,7 @@ function _fnFeatureHtmlFilter ( oSettings ) { nFilter.id = oSettings.sTableId+'_filter'; } - + var jqFilter = $('input[type="search"]', nFilter); // Store a reference to the input element, so other input elements could be @@ -41,7 +41,7 @@ function _fnFeatureHtmlFilter ( oSettings ) $(n[i]._DT_Input).val( val ); } } - + /* Now do the filter */ if ( val != oPreviousSearch.sSearch ) { @@ -68,7 +68,7 @@ function _fnFeatureHtmlFilter ( oSettings ) } } ); - + return nFilter; } @@ -100,7 +100,7 @@ function _fnFilterComplete ( oSettings, oInput, iForce ) fnSaveFilter( oInput ); /* Now do the individual column filter */ - for ( var i=0 ; i