mirror of
https://github.com/DataTables/DataTables.git
synced 2024-11-29 11:24:10 +01:00
API: Selectors - 'filter' selector modifier renamed to be 'search'
- Renaming in keeping with the new terminology - Updating example which uses it (main documentation still to be written) - Backwards compatible with a bit of logic to check if the old version is being passed in
This commit is contained in:
parent
d47da33826
commit
7119dfa50c
@ -1 +1 @@
|
||||
c03c559f0b0a8a815ab1dab80fe72d6806ce78a5
|
||||
9cb6d52a9a3e57a2327bc987d905ef8a55a3846b
|
||||
|
@ -29,7 +29,7 @@ $(document).ready(function() {
|
||||
} );
|
||||
|
||||
t.on( 'order search', function () {
|
||||
t.column(0, {filter:'applied', order:'applied'}).nodes().each( function (cell, i) {
|
||||
t.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
|
||||
cell.innerHTML = i+1;
|
||||
} );
|
||||
} ).draw();
|
||||
@ -567,7 +567,7 @@ $(document).ready(function() {
|
||||
} );
|
||||
|
||||
t.on( 'order search', function () {
|
||||
t.column(0, {filter:'applied', order:'applied'}).nodes().each( function (cell, i) {
|
||||
t.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
|
||||
cell.innerHTML = i+1;
|
||||
} );
|
||||
} ).draw();
|
||||
|
32
media/js/jquery.dataTables.js
vendored
32
media/js/jquery.dataTables.js
vendored
@ -7137,8 +7137,14 @@
|
||||
opts = {};
|
||||
}
|
||||
|
||||
// Backwards compatibility for 1.9- which used the terminology filter rather
|
||||
// than search
|
||||
if ( opts.filter && ! opts.search ) {
|
||||
opts.search = opts.filter;
|
||||
}
|
||||
|
||||
return {
|
||||
filter: opts.filter || 'none',
|
||||
search: opts.search || 'none',
|
||||
order: opts.order || 'current',
|
||||
page: opts.page || 'all'
|
||||
};
|
||||
@ -7174,12 +7180,12 @@
|
||||
displayMaster = settings.aiDisplayMaster;
|
||||
|
||||
var
|
||||
filter = opts.filter, // none, applied, removed
|
||||
order = opts.order, // current, index (original - compatibility with 1.9)
|
||||
page = opts.page; // all, page
|
||||
search = opts.search, // none, applied, removed
|
||||
order = opts.order, // applied, current, index (original - compatibility with 1.9)
|
||||
page = opts.page; // all, current
|
||||
|
||||
// Current page implies that order=current and fitler=applied, since it is
|
||||
// fairly senseless otherwise, regardless of what order and filter actually
|
||||
// fairly senseless otherwise, regardless of what order and search actually
|
||||
// are
|
||||
if ( page == 'current' )
|
||||
{
|
||||
@ -7188,24 +7194,24 @@
|
||||
}
|
||||
}
|
||||
else if ( order == 'current' || order == 'applied' ) {
|
||||
a = filter == 'none' ?
|
||||
displayMaster.slice() : // no filter
|
||||
filter == 'applied' ?
|
||||
displayFiltered.slice() : // applied filter
|
||||
$.map( displayMaster, function (el, i) { // removed filter
|
||||
a = search == 'none' ?
|
||||
displayMaster.slice() : // no search
|
||||
search == 'applied' ?
|
||||
displayFiltered.slice() : // applied search
|
||||
$.map( displayMaster, function (el, i) { // removed search
|
||||
return $.inArray( el, displayFiltered ) === -1 ? el : null;
|
||||
} );
|
||||
}
|
||||
else if ( order == 'index' || order == 'original' ) {
|
||||
for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
|
||||
if ( filter == 'none' ) {
|
||||
if ( search == 'none' ) {
|
||||
a.push( i );
|
||||
}
|
||||
else { // applied | removed
|
||||
tmp = $.inArray( i, displayFiltered );
|
||||
|
||||
if ((tmp === -1 && filter == 'removed') ||
|
||||
(tmp === 1 && filter == 'applied') )
|
||||
if ((tmp === -1 && search == 'removed') ||
|
||||
(tmp === 1 && search == 'applied') )
|
||||
{
|
||||
a.push( i );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user