我正在使用Jquery数据表(内置免费搜索文本),由于性能问题,我决定从客户端切换到服务器端。 此更改后,免费搜索文本已停止响应。 我正在添加更改。 变更之前:
-ConnectionStringName
变更后:
$('#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'));
}
});
此功能是否始终在客户端模式下工作,但在服务器端不起作用?我怎么能克服这个问题?
谢谢
答案 0 :(得分:1)
在客户端处理模式下,搜索,排序和分页由jQuery DataTables插件执行。
当您使用"serverSide": true
启用服务器端处理模式时,您必须在服务器端自行实施搜索,排序和分页。另请注意,使用服务器端处理模式时,响应中应该存在额外的参数。
有关详细信息,请参阅Processing modes。