在数据表中免费搜索停止工作

free search in datatable stop working

我正在使用 Jquery 数据表(内置免费搜索文本),由于性能问题,我决定从客户端切换到服务器端。 此更改后,免费搜索文本已停止响应。 我正在添加更改。 更改前:

$('#table').DataTable({
    "order": [[0, "desc"]],
    "bStateSave": true,
    "fnStateSaveParams": function (oSettings, sValue) {

        $.cookie("CompanySearch", $("#CompanySearch").val(), { expires: 7 });
        $.cookie("PhoneSearch", $("#PhoneSearch").val().replace('-', ''), { expires: 7 });
        $.cookie("TreatmentByFilterDropDown", $("#TreatmentByFilterDropDown").val(), { expires: 7 });
        $.cookie("LastTreatmentByID", $("#LastTreatmentByID").val(), { expires: 7 });
        $.cookie("ReferenceSourceFilterDropDown", $("#ReferenceSourceFilterDropDown").val(), { expires: 7 });
        $.cookie("ProductClassificationFilterDropDown", $("#ProductClassificationFilterDropDown").val(), { expires: 7 });
        $.cookie("ImportanceFilterDropDown", $("#ImportanceFilterDropDown").val(), { expires: 7 });
        $.cookie("openStart", $("#openStart").val(), { expires: 7 });
        $.cookie("openEnd", $("#openEnd").val(), { expires: 7 });
        $.cookie("treatmentStart", $("#treatmentStart").val(), { expires: 7 });
        $.cookie("treatmentEnd", $("#treatmentEnd").val(), { expires: 7 });
        $.cookie("lastTreatmentStart", $("#lastTreatmentStart").val(), { expires: 7 });
        $.cookie("lastTreatmentEnd", $("#lastTreatmentEnd").val(), { expires: 7 });
        $.cookie("StatusFilterDropDown", $("#StatusFilterDropDown").val(), { expires: 7 });


        //alertify.log("States Saved");
    },
    "fnStateLoadParams": function (oSettings, oData) {
        $("#CompanySearch").val($.cookie("CompanySearch"));
        $("#PhoneSearch").val($.cookie("PhoneSearch"));
        $("#TreatmentByFilterDropDown").val($.cookie("TreatmentByFilterDropDown"));
        $("#LastTreatmentByID").val($.cookie("LastTreatmentByID"));
        $("#ReferenceSourceFilterDropDown").val($.cookie("ReferenceSourceFilterDropDown"));
        $("#ProductClassificationFilterDropDown").val($.cookie("ProductClassificationFilterDropDown"));
        $("#ImportanceFilterDropDown").val($.cookie("ImportanceFilterDropDown"));
        $("#openStart").val($.cookie("openStart"));
        $("#openEnd").val($.cookie("openEnd"));
        $("#treatmentStart").val($.cookie("treatmentStart"));
        $("#treatmentEnd").val($.cookie("treatmentEnd"));
        $("#lastTreatmentStart").val($.cookie("lastTreatmentStart"));
        $("#lastTreatmentEnd").val($.cookie("lastTreatmentEnd"));
        $("#StatusFilterDropDown").val($.cookie("StatusFilterDropDown"));

        //alertify.log("States load");
    },
    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
        "sSwfPath": "/Scripts/DataTables-1.10.4/extensions/TableTools/swf/copy_csv_xls.swf",
        "aButtons": [
            {
                "sExtends": "xls",
                "sButtonText": "Save Excel",
                "mColumns": "visible"
            }
        ]
    },
    "pagingType": "full_numbers",
    "language": {
        "sProcessing": "מעבד...",
        "sLengthMenu": "הצג _MENU_ פריטים",
        "sZeroRecords": "לא נמצאו רשומות מתאימות",
        "sInfo": "_START_ עד _END_ מתוך _TOTAL_ רשומות",
        "sInfoEmpty": "0 עד 0 מתוך 0 רשומות",
        "sInfoFiltered": "(מסונן מסך _MAX_  רשומות)",
        "sInfoPostFix": "",
        "sSearch": "חיפוש חופשי:",
        "sUrl": "",
        "oPaginate": {
            "sFirst": "ראשון",
            "sPrevious": "קודם",
            "sNext": "הבא",
            "sLast": "אחרון"
        }
    },
    "aaData": data,
    "columns": [
        { "mDataProp": "ID" },
        { "mDataProp": "OpenDate" },
        { "mDataProp": "NextContactDay" },
        { "mDataProp": "CompanyName" },
        { "mDataProp": "ContactName" },
        { "mDataProp": "Phone" },
        { "mDataProp": "CellPhone" },
        { "mDataProp": "Details" },
        { "mDataProp": "Status" },
        { "mDataProp": "TreatmentBy" },
        { "mDataProp": "TreatmentByID" },
        { "mDataProp": "ReferenceSourceID" },
        { "mDataProp": "ProductClassificationID" },
        { "mDataProp": "ImportanceID" },
        { "mDataProp": "StatusID"  },
        { "mDataProp": "LastTreatmentDate" },
        { "mDataProp": "LastTreatmentBy" },
        { "mDataProp": "LastTreatmentByID" }
    ],
    "columnDefs": [
        { "width": "10%", "targets": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] },
        {"type" : "date", "targets": [1]},
        {
            "targets": [10],
            "visible": false,
        },
        {
            "targets": [11],
            "visible": false
        },
        {
            "targets": [12],
            "visible": false
        },
        {
            "targets": [13],
            "visible": false
        },
        {
            "targets": [14],
            "visible": false
        },
        {
            "targets": [17],
            "visible": false
        },
        {
            "targets": [16],
            "visible": false
        },
        {
            "targets": [15],
            "visible": false
        }
    ],
    "fnInitComplete": function () {
        checkForHiddenFilters();
        $($('.panel')[1]).append($('.DTTT_container'));
    }
});

变更后:

$('#table').DataTable({
    "order": [[0, "desc"]],
    "bStateSave": true,
    "fnStateSaveParams": function (oSettings, sValue) {

        $.cookie("CompanySearch", $("#CompanySearch").val(), { expires: 7 });
        $.cookie("PhoneSearch", $("#PhoneSearch").val().replace('-', ''), { expires: 7 });
        $.cookie("TreatmentByFilterDropDown", $("#TreatmentByFilterDropDown").val(), { expires: 7 });
        $.cookie("LastTreatmentByID", $("#LastTreatmentByID").val(), { expires: 7 });
        $.cookie("ReferenceSourceFilterDropDown", $("#ReferenceSourceFilterDropDown").val(), { expires: 7 });
        $.cookie("ProductClassificationFilterDropDown", $("#ProductClassificationFilterDropDown").val(), { expires: 7 });
        $.cookie("ImportanceFilterDropDown", $("#ImportanceFilterDropDown").val(), { expires: 7 });
        $.cookie("openStart", $("#openStart").val(), { expires: 7 });
        $.cookie("openEnd", $("#openEnd").val(), { expires: 7 });
        $.cookie("treatmentStart", $("#treatmentStart").val(), { expires: 7 });
        $.cookie("treatmentEnd", $("#treatmentEnd").val(), { expires: 7 });
        $.cookie("lastTreatmentStart", $("#lastTreatmentStart").val(), { expires: 7 });
        $.cookie("lastTreatmentEnd", $("#lastTreatmentEnd").val(), { expires: 7 });
        $.cookie("StatusFilterDropDown", $("#StatusFilterDropDown").val(), { expires: 7 });


        //alertify.log("States Saved");
    },
    "fnStateLoadParams": function (oSettings, oData) {
        $("#CompanySearch").val($.cookie("CompanySearch"));
        $("#PhoneSearch").val($.cookie("PhoneSearch"));
        $("#TreatmentByFilterDropDown").val($.cookie("TreatmentByFilterDropDown"));
        $("#LastTreatmentByID").val($.cookie("LastTreatmentByID"));
        $("#ReferenceSourceFilterDropDown").val($.cookie("ReferenceSourceFilterDropDown"));
        $("#ProductClassificationFilterDropDown").val($.cookie("ProductClassificationFilterDropDown"));
        $("#ImportanceFilterDropDown").val($.cookie("ImportanceFilterDropDown"));
        $("#openStart").val($.cookie("openStart"));
        $("#openEnd").val($.cookie("openEnd"));
        $("#treatmentStart").val($.cookie("treatmentStart"));
        $("#treatmentEnd").val($.cookie("treatmentEnd"));
        $("#lastTreatmentStart").val($.cookie("lastTreatmentStart"));
        $("#lastTreatmentEnd").val($.cookie("lastTreatmentEnd"));
        $("#StatusFilterDropDown").val($.cookie("StatusFilterDropDown"));

        //alertify.log("States load");
    },
    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
        "sSwfPath": "/Scripts/DataTables-1.10.4/extensions/TableTools/swf/copy_csv_xls.swf",
        "aButtons": [
            {
                "sExtends": "xls",
                "sButtonText": "Save Excel",
                "mColumns": "visible"
            }
        ]
    },
    "pagingType": "full_numbers",
    "language": {
        "sProcessing": "מעבד...",
        "sLengthMenu": "הצג _MENU_ פריטים",
        "sZeroRecords": "לא נמצאו רשומות מתאימות",
        "sInfo": "_START_ עד _END_ מתוך _TOTAL_ רשומות",
        "sInfoEmpty": "0 עד 0 מתוך 0 רשומות",
        "sInfoFiltered": "(מסונן מסך _MAX_  רשומות)",
        "sInfoPostFix": "",
        "sSearch": "חיפוש חופשי:",
        "sUrl": "",
        "oPaginate": {
            "sFirst": "ראשון",
            "sPrevious": "קודם",
            "sNext": "הבא",
            "sLast": "אחרון"
        }
    },
    "serverSide": true,
    "orderMulti":false,
    "ajax": {
        "url": "/Entreaties/GetEntreaties",
        "data": function (d) { 
            d.status = 0;
            d.firstLoad = firstLoad;                
            d.jAdvanceSearch = JSON.stringify(new AdvanceSearch());
        },
        "type": "POST",
        "dataType": "json",
        error: function (xhr, textStatus, errorThrown) {
            alertify.log(xhr.responseText);
        }
    },
    //"aaData": data,
    "columns": [
        { "data": "ID" },
        { "data": "OpenDate" },
        { "data": "NextContactDay" },
        { "data": "CompanyName" },
        { "data": "ContactName" },
        { "data": "Phone" },
        { "data": "CellPhone" },
        { "data": "Details" },
        { "data": "Status" },
        { "data": "TreatmentBy" },
        { "data": "TreatmentByID" },
        { "data": "ReferenceSourceID" },
        { "data": "ProductClassificationID" },
        { "data": "ImportanceID" },
        { "data": "StatusID"  },
        { "data": "LastTreatmentDate" },
        { "data": "LastTreatmentBy" },
        { "data": "LastTreatmentByID" }
    ],
    "columnDefs": [
        { "width": "10%", "targets": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] },
        {"type" : "date", "targets": [1]},
        {
            "targets": [10],
            "visible": false,
        },
        {
            "targets": [11],
            "visible": false
        },
        {
            "targets": [12],
            "visible": false
        },
        {
            "targets": [13],
            "visible": false
        },
        {
            "targets": [14],
            "visible": false
        },
        {
            "targets": [17],
            "visible": false
        },
        {
            "targets": [16],
            "visible": false
        },
        {
            "targets": [15],
            "visible": false
        }
    ],
    "fnInitComplete": function () {
        checkForHiddenFilters();
        $($('.panel')[1]).append($('.DTTT_container'));           
    }
});

此功能是否总是在客户端模式下有效,但在服务器端模式下无效?我该如何解决这个问题?

谢谢

在 client-side 处理模式下,搜索、排序和分页由 jQuery DataTables 插件执行。

当您使用"serverSide": true启用server-side处理模式时,您必须在server-side上自行实现搜索、排序和分页。另请注意,在使用 server-side 处理模式时,响应中应包含额外的参数。

有关详细信息,请参阅 Processing modes