diff --git a/.datatables-commit-sync b/.datatables-commit-sync index 3e5f90b9..945d6e90 100644 --- a/.datatables-commit-sync +++ b/.datatables-commit-sync @@ -1 +1 @@ -652dee67d398ffbc4d3a44d97f58b6b3721cf554 +3a9f58ffb56298347ab39ca825da9e35d5426aff diff --git a/examples/api/multi_filter.html b/examples/api/multi_filter.html index 9ad41180..760bccbc 100644 --- a/examples/api/multi_filter.html +++ b/examples/api/multi_filter.html @@ -32,20 +32,23 @@ $(document).ready(function() { } ); // DataTable - var table = $('#example').DataTable(); + var table = $('#example').DataTable({ + initComplete: function () { + // Apply the search + this.api().columns().every( function () { + var that = this; - // Apply the search - table.columns().every( function () { - var that = this; + $( 'input', this.footer() ).on( 'keyup change clear', function () { + if ( that.search() !== this.value ) { + that + .search( this.value ) + .draw(); + } + } ); + } ); + } + }); - $( 'input', this.footer() ).on( 'keyup change clear', function () { - if ( that.search() !== this.value ) { - that - .search( this.value ) - .draw(); - } - } ); - } ); } ); @@ -66,7 +69,9 @@ $(document).ready(function() {

This examples shows text elements being used with the column().search() method to add input controls in the footer of the table for each column. Note that the *index*:visible option is used for the column selector to ensure that the column() method takes into account any hidden columns when selecting the column to act upon.

+ "DataTables API method">column() method takes into account any hidden columns when selecting the column to act upon. initComplete is used to allow for any + asynchronous actions, such as Ajax loading of data or language information.

@@ -566,20 +571,23 @@ $(document).ready(function() { } ); // DataTable - var table = $('#example').DataTable(); + var table = $('#example').DataTable({ + initComplete: function () { + // Apply the search + this.api().columns().every( function () { + var that = this; - // Apply the search - table.columns().every( function () { - var that = this; + $( 'input', this.footer() ).on( 'keyup change clear', function () { + if ( that.search() !== this.value ) { + that + .search( this.value ) + .draw(); + } + } ); + } ); + } + }); - $( 'input', this.footer() ).on( 'keyup change clear', function () { - if ( that.search() !== this.value ) { - that - .search( this.value ) - .draw(); - } - } ); - } ); } );

In addition to the above code, the following Javascript library files are loaded for use in this example:

").html(F(a,c,b,"display"))[0]}function Kb(a,b){for(var c, d=-1,e=-1,h=0,g=a.aoData.length;hd&&(d=c.length,e=h);return e}function B(a){return null===a?"0px":"number"==typeof a?0>a?"0px":a+"px":a.match(/\d$/)?a+"px":a}function X(a){var b=[],c=a.aoColumns;var d=a.aaSortingFixed;var e=f.isPlainObject(d);var h=[];var g=function(a){a.length&&!f.isArray(a[0])?h.push(a):f.merge(h,a)};f.isArray(d)&&g(d);e&&d.pre&&g(d.pre);g(a.aaSorting);e&&d.post&&g(d.post);for(a=0;a/g,"");var f=h.nTh;f.removeAttribute("aria-sort");h.bSortable&&(0e?e+1:3))}e=0;for(h=d.length;ee?e+1:3))}a.aLastSort=d}function Lb(a,b){var c=a.aoColumns[b],d=q.ext.order[c.sSortDataType], -e;d&&(e=d.call(a.oInstance,a,b,ba(a,b)));for(var h,g=q.ext.type.order[c.sType+"-pre"],k=0,f=a.aoData.length;k=h.length?[0,c[1]]:c)}));b.search!==n&&f.extend(a.oPreviousSearch,Fb(b.search));if(b.columns)for(d=0,e=b.columns.length;d").appendTo(b);t(x,v)}else{m=null;p=v;x=a.iTabIndex;switch(v){case "ellipsis":b.append('');break;case "first":m=k.sFirst;0===e&&(x=-1,p+=" "+r);break;case "previous":m=k.sPrevious;0===e&&(x=-1,p+= -" "+r);break;case "next":m=k.sNext;e===h-1&&(x=-1,p+=" "+r);break;case "last":m=k.sLast;e===h-1&&(x=-1,p+=" "+r);break;default:m=v+1,p=e===v?g.sPageButtonActive:""}null!==m&&(x=f("",{"class":g.sPageButton+" "+p,"aria-controls":a.sTableId,"aria-label":l[v],"data-dt-idx":q,tabindex:x,id:0===c&&"string"===typeof v?a.sTableId+"_"+v:null}).html(m).appendTo(b),Za(x,{action:v},u),q++)}}};try{var x=f(b).find(w.activeElement).data("dt-idx")}catch(lc){}t(f(b).empty(),d);x!==n&&f(b).find("[data-dt-idx="+ +" "+r);break;case "next":m=k.sNext;if(0===h||e===h-1)x=-1,p+=" "+r;break;case "last":m=k.sLast;e===h-1&&(x=-1,p+=" "+r);break;default:m=v+1,p=e===v?g.sPageButtonActive:""}null!==m&&(x=f("",{"class":g.sPageButton+" "+p,"aria-controls":a.sTableId,"aria-label":l[v],"data-dt-idx":q,tabindex:x,id:0===c&&"string"===typeof v?a.sTableId+"_"+v:null}).html(m).appendTo(b),Za(x,{action:v},u),q++)}}};try{var x=f(b).find(w.activeElement).data("dt-idx")}catch(lc){}t(f(b).empty(),d);x!==n&&f(b).find("[data-dt-idx="+ x+"]").trigger("focus")}}});f.extend(q.ext.type.detect,[function(a,b){b=b.oLanguage.sDecimal;return cb(a,b)?"num"+b:null},function(a,b){if(a&&!(a instanceof Date)&&!cc.test(a))return null;b=Date.parse(a);return null!==b&&!isNaN(b)||P(a)?"date":null},function(a,b){b=b.oLanguage.sDecimal;return cb(a,b,!0)?"num-fmt"+b:null},function(a,b){b=b.oLanguage.sDecimal;return Tb(a,b)?"html-num"+b:null},function(a,b){b=b.oLanguage.sDecimal;return Tb(a,b,!0)?"html-num-fmt"+b:null},function(a,b){return P(a)||"string"=== typeof a&&-1!==a.indexOf("<")?"html":null}]);f.extend(q.ext.type.search,{html:function(a){return P(a)?a:"string"===typeof a?a.replace(Qb," ").replace(Da,""):""},string:function(a){return P(a)?a:"string"===typeof a?a.replace(Qb," "):a}});var Ca=function(a,b,c,d){if(0!==a&&(!a||"-"===a))return-Infinity;b&&(a=Sb(a,b));a.replace&&(c&&(a=a.replace(c,"")),d&&(a=a.replace(d,"")));return 1*a};f.extend(C.type.order,{"date-pre":function(a){a=Date.parse(a);return isNaN(a)?-Infinity:a},"html-pre":function(a){return P(a)? "":a.replace?a.replace(/<.*?>/g,"").toLowerCase():a+""},"string-pre":function(a){return P(a)?"":"string"===typeof a?a.toLowerCase():a.toString?a.toString():""},"string-asc":function(a,b){return ab?1:0},"string-desc":function(a,b){return ab?-1:0}});Ga("");f.extend(!0,q.ext.renderer,{header:{_:function(a,b,c,d){f(a.nTable).on("order.dt.DT",function(e,f,g,k){a===f&&(e=c.idx,b.removeClass(c.sSortingClass+" "+d.sSortAsc+" "+d.sSortDesc).addClass("asc"==k[e]?d.sSortAsc:"desc"==k[e]?d.sSortDesc: