0

I am getting this error in the console :

 "Uncaught TypeError: Object [object Object] has no method 'fnFilterClear'"

My code :

$(document).ready(function () {

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

$('#csearchtext').bind("change paste keyup", function () {
    var input = $('#csearchtext').val();
    var dropdownindex = $("select[name='columnlist'] option:selected").index();

    console.log(dropdownindex);

    $('#table_id').dataTable().fnFilter(input, dropdownindex + 1, false, true, true, false);
});

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

    $('#table_id').dataTable().fnFilterClear();

});

$('#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"]
                }]
        }
    });
 }
});

The javascript is firing just fine but the one spot that triggers the fnfilterclear has that error prompted.

4

1 回答 1

1

查看http://datatables.net/plug-ins/api#how_to如何使用 Datatable Plug-in API。您必须包含该页面上列出的功能才能使用该功能。

要使用以下插件 API 函数之一,您只需在加载 DataTables 库之后、初始化 DataTable 之前将其包含在页面可用的 Javascript 中。之后,您将能够初始化表,并在结果对象上调用函数。

于 2013-09-13T15:12:43.120 回答