mirror of
https://github.com/DataTables/DataTables.git
synced 2024-12-01 13:24:10 +01:00
Fix: Custom filter was running through the rows in reverse
* Originally this was done because it makes removing items a little bit easier with Array.splice(), however, it doesn't make any sense to go through the rows in reverse if there might be an interdependency between the rows. * It has never been documented what order the rows are filtered in, so I think this is a safe change to make. * I've also added the row display index to the parameters passed in
This commit is contained in:
parent
96b7ef9176
commit
3ea905201b
@ -1 +1 @@
|
|||||||
014b64c0781cdf68073d51d5ca8e46a45425bbbd
|
f07529f7ddf780f9668356727be62df70b3da153
|
||||||
|
16
media/js/jquery.dataTables.js
vendored
16
media/js/jquery.dataTables.js
vendored
@ -2767,15 +2767,23 @@
|
|||||||
var displayRows = settings.aiDisplay;
|
var displayRows = settings.aiDisplay;
|
||||||
var row, rowIdx;
|
var row, rowIdx;
|
||||||
|
|
||||||
for ( var i=0, iLen=filters.length ; i<iLen ; i++ ) {
|
for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
|
||||||
for ( var j=displayRows.length-1 ; j>=0 ; j-- ) {
|
var rows = [];
|
||||||
|
|
||||||
|
// Loop over each row and see if it should be included
|
||||||
|
for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
|
||||||
rowIdx = displayRows[ j ];
|
rowIdx = displayRows[ j ];
|
||||||
row = settings.aoData[ rowIdx ];
|
row = settings.aoData[ rowIdx ];
|
||||||
|
|
||||||
if ( ! filters[i]( settings, row._aFilterData, rowIdx, row._aData ) ) {
|
if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
|
||||||
displayRows.splice( j, 1 );
|
rows.push( rowIdx );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// So the array reference doesn't break set the results into the
|
||||||
|
// existing array
|
||||||
|
displayRows.length = 0;
|
||||||
|
displayRows.push.apply( displayRows, rows );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user