Skip to content

Instantly share code, notes, and snippets.

@tigrang
Last active April 4, 2016 16:21
Show Gist options
  • Save tigrang/e6b9d53a407280f791f3abceea285394 to your computer and use it in GitHub Desktop.
Save tigrang/e6b9d53a407280f791f3abceea285394 to your computer and use it in GitHub Desktop.
<h2>Column Filter</h2>
<?php $this->start('tfoot'); ?>
<tr>
<th><input type="text" placeholder="Search id"/></th>
<th><input type="text" placeholder="Search username"/></th>
<th><input type="text" placeholder="Search created at"/></th>
<th><input type="text" placeholder="Search updated at"/></th>
<th></th>
</tr>
<?php $this->end(); ?>
<?php
echo $this->DataTable->render('User', [
'id' => 'UsersTable',
'tfoot' => $this->fetch('tfoot'),
]);
?>
<?php $this->Html->scriptStart(['block' => 'table_extras']); ?>
$(document).ready(function() {
var table = $('#UsersTable');
var oTable = table.dataTable();
$("#UsersTable tfoot input").keyup(function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter(this.value, $("tfoot input").index(this));
});
});
<?php $this->Html->scriptEnd(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment