0

Uncaught TypeError: Object [object Object] has no method 'fnFilter'

$(document).ready(function () {

var selectedColumn = $('#columnlist').find(":selected").text();

$('#csearchtext').bind("change paste keyup", function () {
    var input = $('#csearchtext').val();

    console.log(input);

    $('#table_id').fnFilter('',4);
});

$('#dblist').on('change', function () {

    var selected = $('#dblist').find(":selected").text();
    tablefill(selected);

});

$('#search').click(function () {

    var selected = $('#dblist').find(":selected").text();
    tablefill(selected);

});

function tablefill(selected) {
    $('.advsearchbar').show();
    $('#stable').show();

    $('#table_id').dataTable({
        "sAjaxSource": '/php/connect/searchtablequery.php',
        "bProcessing": true,
        "sScrollY": "500px",
        "bDeferRender": true,
        "bDestroy": true,
        "sAjaxDataProp": "",
        "fnServerParams": function (aoData) {
            aoData.push({ "name": "db", "value": selected });
        },
        "aoColumns": [
            { "mData": "calldate" },
            { "mData": "recordingfile" },
            { "mData": "uniqueid" },
            { "mData": "src" },
            { "mData": "did" },
            { "mData": "lastapp" },
            { "mData": "dst" },
            { "mData": "disposition" },
            { "mData": "duration" },
            { "mData": "userfield" },
            { "mData": "accountcode"}],
        "iDisplayLength": 20,
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "sDom": '<"H"Tfr>t<"F"ip>',
        "oTableTools": {
            "sSwfPath": "/DataTables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf",
            "aButtons": [
                "copy", "csv", "xls", "pdf",
                {
                    "sExtends": "collection",
                    "sButtonText": "Save",
                    "aButtons": ["csv", "xls", "pdf"]
                }]
        }
    });
}

});

Uncaught TypeError: Object [object Object] has no method 'fnFilter' I am not sure why this is happening the jquery is included because the datatable is being created just fine. Any help on this will be great.

3
  • can you show me where your displaying it? Commented Sep 12, 2013 at 21:31
  • As in the site that it is hosted on ? Commented Sep 12, 2013 at 21:34
  • just like the table layout because when it happened to me i did not have enough rows in my aoColumns Commented Sep 12, 2013 at 21:35

2 Answers 2

3

You have to chain with dataTable object, like this..

$('#table_id').dataTable().fnFilter('', 4);
Sign up to request clarification or add additional context in comments.

3 Comments

That got the error to go away but the table is not filtering anything lol
You try to filter with an empty string!
i derped forgot to change it to a variable, Thank you will mark as answer as soon as possible.
2

You need to get the dataTable object, instead of the jQuery object.

$('#table_id').dataTable().fnFilter('',4);

From the docs:

$(document).ready(function() {
  var oTable = $('#example').dataTable();

  // Sometime later - filter...
  oTable.fnFilter( 'test string' );
} );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.