1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-11-28 10:24:10 +01:00

Update - example: Use initComplete for column filter example

This commit is contained in:
Allan Jardine 2020-05-21 09:52:15 +00:00
parent f26ec6052f
commit 05414e1437
2 changed files with 34 additions and 26 deletions

View File

@ -1 +1 @@
7a4382d11a7db5cae5e4b9311564c741b70c7dfd
6bda0abd0cade0b2795f938b2a1d1686c3176024

View File

@ -32,10 +32,10 @@ $(document).ready(function() {
} );
// DataTable
var table = $('#example').DataTable();
var table = $('#example').DataTable({
initComplete: function () {
// Apply the search
table.columns().every( function () {
this.api().columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change clear', function () {
@ -46,6 +46,9 @@ $(document).ready(function() {
}
} );
} );
}
});
} );
@ -66,7 +69,9 @@ $(document).ready(function() {
<p>This examples shows text elements being used with the <a href="//datatables.net/reference/api/column().search()"><code class="api" title=
"DataTables API method">column().search()</code></a> method to add input controls in the footer of the table for each column. Note that the
<code>*index*:visible</code> option is used for the column selector to ensure that the <a href="//datatables.net/reference/api/column()"><code class="api" title=
"DataTables API method">column()</code></a> method takes into account any hidden columns when selecting the column to act upon.</p>
"DataTables API method">column()</code></a> method takes into account any hidden columns when selecting the column to act upon. <a href=
"//datatables.net/reference/option/initComplete"><code class="option" title="DataTables initialisation option">initComplete</code></a> is used to allow for any
asynchronous actions, such as Ajax loading of data or language information.</p>
</div>
<div class="demo-html"></div>
<table id="example" class="display" style="width:100%">
@ -566,10 +571,10 @@ $(document).ready(function() {
} );
// DataTable
var table = $('#example').DataTable();
var table = $('#example').DataTable({
initComplete: function () {
// Apply the search
table.columns().every( function () {
this.api().columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change clear', function () {
@ -580,6 +585,9 @@ $(document).ready(function() {
}
} );
} );
}
});
} );</code>
<p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
<ul>