mirror of
https://github.com/DataTables/DataTables.git
synced 2025-03-15 16:29:16 +01:00
Fix: Modify the filtering such that client-side filtering is not done when server-side processing is enabled - its just a waste of time since hte server will do it all - 7825
This commit is contained in:
parent
3f9b7430f1
commit
74f3426284
49
media/js/jquery.dataTables.js
vendored
49
media/js/jquery.dataTables.js
vendored
@ -2029,21 +2029,39 @@
|
|||||||
*/
|
*/
|
||||||
function _fnFilterComplete ( oSettings, oInput, iForce )
|
function _fnFilterComplete ( oSettings, oInput, iForce )
|
||||||
{
|
{
|
||||||
/* Filter on everything */
|
var oPrevSearch = oSettings.oPreviousSearch;
|
||||||
_fnFilter( oSettings, oInput.sSearch, iForce, oInput.bRegex, oInput.bSmart, oInput.bCaseInsensitive );
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
/* Now do the individual column filter */
|
/* In server-side processing all filtering is done by the server, so no point hanging around here */
|
||||||
for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ )
|
if ( !oSettings.oFeatures.bServerSide )
|
||||||
{
|
{
|
||||||
_fnFilterColumn( oSettings, oSettings.aoPreSearchCols[i].sSearch, i,
|
/* Global filter */
|
||||||
oSettings.aoPreSearchCols[i].bRegex, oSettings.aoPreSearchCols[i].bSmart,
|
_fnFilter( oSettings, oInput.sSearch, iForce, oInput.bRegex, oInput.bSmart, oInput.bCaseInsensitive );
|
||||||
oSettings.aoPreSearchCols[i].bCaseInsensitive );
|
fnSaveFilter( oInput );
|
||||||
|
|
||||||
|
/* Now do the individual column filter */
|
||||||
|
for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ )
|
||||||
|
{
|
||||||
|
_fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, aoPrevSearch[i].bRegex,
|
||||||
|
aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Custom filtering */
|
||||||
|
if ( DataTable.ext.afnFiltering.length !== 0 )
|
||||||
|
{
|
||||||
|
_fnFilterCustom( oSettings );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* Custom filtering */
|
|
||||||
if ( DataTable.ext.afnFiltering.length !== 0 )
|
|
||||||
{
|
{
|
||||||
_fnFilterCustom( oSettings );
|
fnSaveFilter( oInput );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tell the draw function we have been filtering */
|
/* Tell the draw function we have been filtering */
|
||||||
@ -2133,6 +2151,7 @@
|
|||||||
{
|
{
|
||||||
var i;
|
var i;
|
||||||
var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive );
|
var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive );
|
||||||
|
var oPrevSearch = oSettings.oPreviousSearch;
|
||||||
|
|
||||||
/* Check if we are forcing or not - optional parameter */
|
/* Check if we are forcing or not - optional parameter */
|
||||||
if ( !iForce )
|
if ( !iForce )
|
||||||
@ -2161,8 +2180,8 @@
|
|||||||
* then the old one (i.e. delete). Search from the master array
|
* then the old one (i.e. delete). Search from the master array
|
||||||
*/
|
*/
|
||||||
if ( oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length ||
|
if ( oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length ||
|
||||||
oSettings.oPreviousSearch.sSearch.length > sInput.length || iForce == 1 ||
|
oPrevSearch.sSearch.length > sInput.length || iForce == 1 ||
|
||||||
sInput.indexOf(oSettings.oPreviousSearch.sSearch) !== 0 )
|
sInput.indexOf(oPrevSearch.sSearch) !== 0 )
|
||||||
{
|
{
|
||||||
/* Nuke the old display array - we are going to rebuild it */
|
/* Nuke the old display array - we are going to rebuild it */
|
||||||
oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
|
oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
|
||||||
@ -2200,10 +2219,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oSettings.oPreviousSearch.sSearch = sInput;
|
|
||||||
oSettings.oPreviousSearch.bRegex = bRegex;
|
|
||||||
oSettings.oPreviousSearch.bSmart = bSmart;
|
|
||||||
oSettings.oPreviousSearch.bCaseInsensitive = bCaseInsensitive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,21 +70,39 @@ function _fnFeatureHtmlFilter ( oSettings )
|
|||||||
*/
|
*/
|
||||||
function _fnFilterComplete ( oSettings, oInput, iForce )
|
function _fnFilterComplete ( oSettings, oInput, iForce )
|
||||||
{
|
{
|
||||||
/* Filter on everything */
|
var oPrevSearch = oSettings.oPreviousSearch;
|
||||||
_fnFilter( oSettings, oInput.sSearch, iForce, oInput.bRegex, oInput.bSmart, oInput.bCaseInsensitive );
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
/* Now do the individual column filter */
|
/* In server-side processing all filtering is done by the server, so no point hanging around here */
|
||||||
for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ )
|
if ( !oSettings.oFeatures.bServerSide )
|
||||||
{
|
{
|
||||||
_fnFilterColumn( oSettings, oSettings.aoPreSearchCols[i].sSearch, i,
|
/* Global filter */
|
||||||
oSettings.aoPreSearchCols[i].bRegex, oSettings.aoPreSearchCols[i].bSmart,
|
_fnFilter( oSettings, oInput.sSearch, iForce, oInput.bRegex, oInput.bSmart, oInput.bCaseInsensitive );
|
||||||
oSettings.aoPreSearchCols[i].bCaseInsensitive );
|
fnSaveFilter( oInput );
|
||||||
|
|
||||||
|
/* Now do the individual column filter */
|
||||||
|
for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ )
|
||||||
|
{
|
||||||
|
_fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, aoPrevSearch[i].bRegex,
|
||||||
|
aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Custom filtering */
|
||||||
|
if ( DataTable.ext.afnFiltering.length !== 0 )
|
||||||
|
{
|
||||||
|
_fnFilterCustom( oSettings );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/* Custom filtering */
|
|
||||||
if ( DataTable.ext.afnFiltering.length !== 0 )
|
|
||||||
{
|
{
|
||||||
_fnFilterCustom( oSettings );
|
fnSaveFilter( oInput );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tell the draw function we have been filtering */
|
/* Tell the draw function we have been filtering */
|
||||||
@ -174,6 +192,7 @@ function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart, bCaseInsensitive
|
|||||||
{
|
{
|
||||||
var i;
|
var i;
|
||||||
var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive );
|
var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive );
|
||||||
|
var oPrevSearch = oSettings.oPreviousSearch;
|
||||||
|
|
||||||
/* Check if we are forcing or not - optional parameter */
|
/* Check if we are forcing or not - optional parameter */
|
||||||
if ( !iForce )
|
if ( !iForce )
|
||||||
@ -202,8 +221,8 @@ function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart, bCaseInsensitive
|
|||||||
* then the old one (i.e. delete). Search from the master array
|
* then the old one (i.e. delete). Search from the master array
|
||||||
*/
|
*/
|
||||||
if ( oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length ||
|
if ( oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length ||
|
||||||
oSettings.oPreviousSearch.sSearch.length > sInput.length || iForce == 1 ||
|
oPrevSearch.sSearch.length > sInput.length || iForce == 1 ||
|
||||||
sInput.indexOf(oSettings.oPreviousSearch.sSearch) !== 0 )
|
sInput.indexOf(oPrevSearch.sSearch) !== 0 )
|
||||||
{
|
{
|
||||||
/* Nuke the old display array - we are going to rebuild it */
|
/* Nuke the old display array - we are going to rebuild it */
|
||||||
oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
|
oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
|
||||||
@ -241,10 +260,6 @@ function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart, bCaseInsensitive
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oSettings.oPreviousSearch.sSearch = sInput;
|
|
||||||
oSettings.oPreviousSearch.bRegex = bRegex;
|
|
||||||
oSettings.oPreviousSearch.bSmart = bSmart;
|
|
||||||
oSettings.oPreviousSearch.bCaseInsensitive = bCaseInsensitive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user