mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-19 17:54:14 +01:00
Fix: If you had a column which has columns.visible:false
set on it, it
would be removed from the array of data passed through to the custom filtering functions. This would cause indexes to misalign. - The fix is to simply pass in the data filter array that has already been computed, as that is 1:1 for the display. Also added the raw data source object for the row for completeness and a bit of a code tidy up. - This will cause a bit of an indexing issue, if you have bVisible:false set, but this is certainly a bug that had to be fixed - it just didn't make sense as it was, and went against the documentation! - See thread 19593 for more information
This commit is contained in:
parent
a14bfa29fb
commit
4834aa26be
@ -1 +1 @@
|
||||
200867a517bb0090f102b7d61f5420912d65f633
|
||||
964addd063b9c201c9206e4fd21aed712c2dd42e
|
||||
|
52
media/js/jquery.dataTables.js
vendored
52
media/js/jquery.dataTables.js
vendored
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/*jslint evil: true, undef: true, browser: true */
|
||||
/*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidateRow,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnScrollBarWidth,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
|
||||
/*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidateRow,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnScrollBarWidth,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
|
||||
|
||||
(/** @lends <global> */function( window, document, undefined ) {
|
||||
|
||||
@ -991,26 +991,6 @@
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an array of data for a given row from the internal data cache
|
||||
* @param {object} oSettings dataTables settings object
|
||||
* @param {int} iRow aoData row id
|
||||
* @param {string} sSpecific data get type ('type' 'filter' 'sort')
|
||||
* @param {array} aiColumns Array of column indexes to get data from
|
||||
* @returns {array} Data array
|
||||
* @memberof DataTable#oApi
|
||||
*/
|
||||
function _fnGetRowData( oSettings, iRow, sSpecific, aiColumns )
|
||||
{
|
||||
var out = [];
|
||||
for ( var i=0, iLen=aiColumns.length ; i<iLen ; i++ )
|
||||
{
|
||||
out.push( _fnGetCellData( oSettings, iRow, aiColumns[i], sSpecific ) );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the data for a given cell from the internal cache, taking into account data mapping
|
||||
* @param {object} oSettings dataTables settings object
|
||||
@ -2688,28 +2668,19 @@
|
||||
* @param {object} oSettings dataTables settings object
|
||||
* @memberof DataTable#oApi
|
||||
*/
|
||||
function _fnFilterCustom( oSettings )
|
||||
function _fnFilterCustom( settings )
|
||||
{
|
||||
var afnFilters = DataTable.ext.search;
|
||||
var aiFilterColumns = _fnGetColumns( oSettings, 'bSearchable' );
|
||||
var filters = DataTable.ext.search;
|
||||
var displayRows = settings.aiDisplay;
|
||||
var row, rowIdx;
|
||||
|
||||
for ( var i=0, iLen=afnFilters.length ; i<iLen ; i++ )
|
||||
{
|
||||
var iCorrector = 0;
|
||||
for ( var j=0, jLen=oSettings.aiDisplay.length ; j<jLen ; j++ )
|
||||
{
|
||||
var iDisIndex = oSettings.aiDisplay[j-iCorrector];
|
||||
var bTest = afnFilters[i](
|
||||
oSettings,
|
||||
_fnGetRowData( oSettings, iDisIndex, 'filter', aiFilterColumns ),
|
||||
iDisIndex
|
||||
);
|
||||
for ( var i=0, iLen=filters.length ; i<iLen ; i++ ) {
|
||||
for ( var j=displayRows.length-1 ; j>=0 ; j-- ) {
|
||||
rowIdx = displayRows[ j ];
|
||||
row = settings.aoData[ rowIdx ];
|
||||
|
||||
/* Check if we should use this row based on the filtering function */
|
||||
if ( !bTest )
|
||||
{
|
||||
oSettings.aiDisplay.splice( j-iCorrector, 1 );
|
||||
iCorrector++;
|
||||
if ( ! filters[i]( settings, row._aFilterData, rowIdx, row._aData ) ) {
|
||||
displayRows.splice( j, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -13967,7 +13938,6 @@
|
||||
_fnAddTr: _fnAddTr,
|
||||
_fnNodeToDataIndex: _fnNodeToDataIndex,
|
||||
_fnNodeToColumnIndex: _fnNodeToColumnIndex,
|
||||
_fnGetRowData: _fnGetRowData,
|
||||
_fnGetCellData: _fnGetCellData,
|
||||
_fnSetCellData: _fnSetCellData,
|
||||
_fnSplitObjNotation: _fnSplitObjNotation,
|
||||
|
Loading…
x
Reference in New Issue
Block a user