JQuery DataTables – Remove fnFilter and display all results

I current have a datatable that has a button for each record that when clicked displays other information for that account. When this happens, I call fnFilter() to filter that specific row so that no other ones are displayed and the user knows that the sub-information I display is for that specific account. What I would like to do, is when a user clicks back in the search toolbar, it hides the sub-information I displayed, then clears the filter and shows all the original records available. Everything works fine, except that the filter doesnt get cleared so only the originally selected row is still displayed.

Not sure what I am missing. I have tried everything from using fnFilter(”), to fnDraw(), to fnReloadAjax(). None of these (or any combination) seem to work!

UPDATE I seemed to have isolated the problem. If I remove the column # from the fnFilter(accountid,7), using fnFilter(”) does re-display all records. However, I really need to filter by that specific column as it is the only column that contains unique values for each record. Any ideas? I did try using fnFilter(”,null) but no success.

Here is my code:

var oTable = $('.mypbhs_accounts').dataTable({
        "bProcessing": true,
        "sAjaxSource": 'sql/mypbhs_accounts.php',      
        "aaSorting": [[1, "asc" ]],
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        //"bStateSave": true, //Use a cookie to save current display of items
        "aoColumns": [
            {"asSorting": [  ], "sClass":"center"},
            null,
            null,
            null,
            null,
            null,
            null,
            { "bSearchable": true, "bVisible": false },       
            { "bSearchable": true, "bVisible": false }       
        ],
        "bScrollCollapse": true,
        "sScrollX": "100%",
         "fnInitComplete": function() {
                oTable.fnAdjustColumnSizing();
         }
    });
/*** CLEAR CURRENT ACCOUNT INFO ***/
$(document).on('click','.mypbhs_content .dataTables_filter',function(){ //THIS IS CALLED WHEN USER CLICKS INTO THE SEARCH BAR
    $('.mypbhs_content .dataTables_filter :input').val(''); //CLEAR CURRENT VALUE IN THE SEARCH BAR
    oTable.fnFilter('');
    //oTable.fnDraw();
    //oTable.fnReloadAjax();
    $('.mypbhs_truform_info').empty(); //REMOVE SUB-INFORMATION SO IT DOESNT GET ASSOCIATED WITH WRONG ACCOUNT
    $('.control_bar').children('ul.mypbhs_account_controls').empty();
});

Datatables fnFilter Delay loader/indicator

I am using datatables with a custom plugin I got from here fnSetFilteringDelay but wanted to add an indicator or loader of some sort to tell the user when the search will happen on the typed text in t

jQuery DataTables – Remove Label

I’m trying to remove the words Search: from the filter label in DataTables. I have tried to use jQuery to replace the label dom but when replaced the filter will not work. Any one have any other sol

jQuery DataTables display All Records as an option

I’m using a purchased Admin theme for a web app that I’m building. That theme came with styles for jQuery dataTables. I’m trying to figure out how to add a View All Records option to the records per p

jQuery DataTables fnFilter: find the exact match of a string within a concatenated string

I am using datatables and am trying to filter my table based on the presence of an ID in a hidden column. The hidden column contains multiple IDs and they are delimited by @ signs, e.g. @[email protected]@354

jQuery / DataTables: remove sorting arrows

I am using the jQuery DataTables plugin. Is there a way I can get rid of the little arrows they display in the headers to indicate sorting options ? I would like to keep the functionality that by cli

jQuery Datatables: display empty table message

i use jQuery Datatables to display some Data. It works perfect but in case the server provides no data, the plugin gives the following warning: DataTables warning (table id = ‘notes’): DataTables war

delete all datatables using jQuery

so, I am using datatables along with jQuery, and am a bit stumped as to why this is not working. My HTML looks like this: <table id=surnamePrimaryPartitionTable border=1 class=display partitionD

jquery datatables display product link in table

I am using jquery datatables to display a large amount of data with child rows and individual column filtering etc…. I am importing all of my data via a json txt file. I need to be able to link the

Applying fnFilter for multiple tables at once using jquery datatable

For the following condition which applies dataTable function to all the tables with class name sort var adminTables = $(‘.sort’).dataTable() How do I apply fnFilter(‘some string’) function to all t

How to display custom processing message in JQuery datatables

i am using datatables api to display data in my asp.net4.0 application; datatables I have one column [ Delete ] to delete the row data.when i click on this link i send a jquery ajax request to delete

Answers

Ah I seemed to have figured it out. Have to clear out the filter on that specific column AND the global filter:

oTable.fnFilter('',7);
oTable.fnFilter('');
"sPaginationType" : "bootstrap",
"iDisplayLength": 25,
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
"bStateSave" : false,

if you want to save the search results then mention

"sPaginationType" : "bootstrap",
"iDisplayLength": 25,
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
"bStateSave" : true,

For me this plugin worked great:

https://datatables.net/plug-ins/api/fnFilterClear

It is simple to clear all filters using Datatables > 1.10:

oTable.search( '' ).columns().search( '' ).draw();