Hi,
I love the datatables framework, but have used it for very standard things so far. I am currently stuck trying to implement a Check box which will hide/ unhide rows in a populated Data Table (via a periodic Ajax.reload()) based on a search in a specific column.
After reviewing the API and other forum items, it looks like l need the columns.search functionality.
var eventTable = $('#event-table').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
url: '<?php echo $_SERVER['PHP_SELF']; ?>',
method: "POST",
data: {
. .. . .... ... other code .........
// Set the Interval Poller
setInterval(function () {
eventTable.ajax.reload();
// Set the time inside the browser
var localTime = getLocalBrowserTimeAsString();
$('#last_refreshed_time').text(localTime);
}, <?php echo $AUTO_REFRESH_PERIOD * 1000; ?>);
// Set the Hide completed Event listenter
$('#hide_completed').change(function () {
if (this.checked) {
// NOT WORKING - DOES NOTHING
eventTable.column(0).search('WEST').draw();
} else {
// NOT WORKING - DOES NOTHING
eventTable.column(0).search('EAST').draw();
}
});
I used both column(0).search and columns(0).search, but neither appear to do anything and there are no javascript exceptions being thrown.
Three questions:
1) what am l doing wrong above?
2) how would l use the RegEx functionality to search for anything not equal to 'WEST'?
3) how do l hold state, so that when the Ajax.reload() request happens, that the checkbox-filter remains?
Any help that you can provide would be gratefully appreciated .. since l am tearing my hair out .. trying to get this done.