mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-19 17:54:14 +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.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;
|
cell.innerHTML = i+1;
|
||||||
} );
|
} );
|
||||||
} ).draw();
|
} ).draw();
|
||||||
@ -567,7 +567,7 @@ $(document).ready(function() {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
t.on( 'order search', 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;
|
cell.innerHTML = i+1;
|
||||||
} );
|
} );
|
||||||
} ).draw();
|
} ).draw();
|
||||||
|
32
media/js/jquery.dataTables.js
vendored
32
media/js/jquery.dataTables.js
vendored
@ -7137,8 +7137,14 @@
|
|||||||
opts = {};
|
opts = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Backwards compatibility for 1.9- which used the terminology filter rather
|
||||||
|
// than search
|
||||||
|
if ( opts.filter && ! opts.search ) {
|
||||||
|
opts.search = opts.filter;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
filter: opts.filter || 'none',
|
search: opts.search || 'none',
|
||||||
order: opts.order || 'current',
|
order: opts.order || 'current',
|
||||||
page: opts.page || 'all'
|
page: opts.page || 'all'
|
||||||
};
|
};
|
||||||
@ -7174,12 +7180,12 @@
|
|||||||
displayMaster = settings.aiDisplayMaster;
|
displayMaster = settings.aiDisplayMaster;
|
||||||
|
|
||||||
var
|
var
|
||||||
filter = opts.filter, // none, applied, removed
|
search = opts.search, // none, applied, removed
|
||||||
order = opts.order, // current, index (original - compatibility with 1.9)
|
order = opts.order, // applied, current, index (original - compatibility with 1.9)
|
||||||
page = opts.page; // all, page
|
page = opts.page; // all, current
|
||||||
|
|
||||||
// Current page implies that order=current and fitler=applied, since it is
|
// 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
|
// are
|
||||||
if ( page == 'current' )
|
if ( page == 'current' )
|
||||||
{
|
{
|
||||||
@ -7188,24 +7194,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( order == 'current' || order == 'applied' ) {
|
else if ( order == 'current' || order == 'applied' ) {
|
||||||
a = filter == 'none' ?
|
a = search == 'none' ?
|
||||||
displayMaster.slice() : // no filter
|
displayMaster.slice() : // no search
|
||||||
filter == 'applied' ?
|
search == 'applied' ?
|
||||||
displayFiltered.slice() : // applied filter
|
displayFiltered.slice() : // applied search
|
||||||
$.map( displayMaster, function (el, i) { // removed filter
|
$.map( displayMaster, function (el, i) { // removed search
|
||||||
return $.inArray( el, displayFiltered ) === -1 ? el : null;
|
return $.inArray( el, displayFiltered ) === -1 ? el : null;
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
else if ( order == 'index' || order == 'original' ) {
|
else if ( order == 'index' || order == 'original' ) {
|
||||||
for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
|
for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
|
||||||
if ( filter == 'none' ) {
|
if ( search == 'none' ) {
|
||||||
a.push( i );
|
a.push( i );
|
||||||
}
|
}
|
||||||
else { // applied | removed
|
else { // applied | removed
|
||||||
tmp = $.inArray( i, displayFiltered );
|
tmp = $.inArray( i, displayFiltered );
|
||||||
|
|
||||||
if ((tmp === -1 && filter == 'removed') ||
|
if ((tmp === -1 && search == 'removed') ||
|
||||||
(tmp === 1 && filter == 'applied') )
|
(tmp === 1 && search == 'applied') )
|
||||||
{
|
{
|
||||||
a.push( i );
|
a.push( i );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user