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

时间:2016-06-14 03:28:05

标签: c# asp.net-mvc datatables asp.net-mvc-5.2 mvc.jquery.datatables

我相信这是因为我的上一个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
}

我该怎么办才能让它再次发挥作用?

1 个答案:

答案 0 :(得分:1)

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

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