Mvc.JQuery.DataTables 列过滤器停止工作

Mvc.JQuery.DataTables column filters stopped working

我相信这发生在我上次 NuGet 包从 1.3.42 升级到 1.3.44 之后。

Report.cshtml:

@using Company.Controllers
@using Mvc.JQuery.DataTables
@using Mvc.JQuery.DataTables.Serialization

@{
     ViewBag.Title = "Report";
     Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Styles {
    @Styles.Render("~/CSS/mvcdatatables")
}

@section Scripts {
    @Scripts.Render("~/bundles/mvcdatatables")
}

<div>
    <h1>Report for @ViewBag.ProjectName</h1>
</div>

@{
    var vm = Html.DataTableVm("table-id", (ProjectsController p) => p.GetReportData(null));

    vm.Dom = "Blfrtip";
    vm.LengthMenu = LengthMenuVm.Default();
    vm.PageLength = 25;
    vm.ColVis = false;
    vm.UseColumnFilterPlugin = true;
    vm.TableTools = true;
}

@Html.Partial("DataTable", vm)

当我在列过滤器中输入任何搜索词时,不再进行过滤。我在 GetReportData 中看到的是 DataTablesParam 没有再填写任何 sSearchValues

public DataTablesResult<VariableModel> GetReportDataCore(DataTablesParam dataTableParam, /* ... params omitted */)
{
    ...
    reportItems = ...  // Details doesn't matter how I obtain these, it works, the view lists the name value pairs
    var queryable = reportItems.InterceptWith(new SetComparerExpressionVisitor(StringComparison.CurrentCultureIgnoreCase));
    return DataTablesResult.Create(queryable, dataTableParam, (ResponseOptions<VariableModel>)null);
}

1.3.44 升级后我试过:

@{
    var vm = Html.DataTableVm("table-id", (ProjectsController p) => p.GetReportData(null));

    vm.Dom = "Blfrtip";
    vm.LengthMenu = LengthMenuVm.Default();
    vm.PageLength = 25;
    vm.ColVis = false;
    vm.Filter = true;
    vm.ShowFilterInput = true;
    vm.UseColumnFilterPlugin = true;
    vm.TableTools = true;
    vm.FilterOn("VariableName").Text().FilterOn("Value").Text();  // Even this
}

我应该怎么做才能让它恢复正常?

这是包中缺少文件的副作用:https://github.com/mcintyre321/mvc.jquery.datatables/issues/148

已经有一个新的 NuGet 包可用 (v 1.3.45) 解决了这个问题:https://github.com/mcintyre321/mvc.jquery.datatables/issues/149