MVC: - 整合mvc6.grid

时间:2017-06-09 07:36:15

标签: asp.net-core-mvc mvcgrid.net

我想整合mvc6.grid,我按照步骤操作,但在视图中出错。错误“'HtmlHelper< IEnumerable< SchemeMaster>>'不包含'网格'的定义“。

模型: -

 public partial class SchemeMaster
    {
        public int SchemeID { get; set; }
        public string SchemeName { get; set; }
        public Nullable<int> Createdby { get; set; }
        public Nullable<System.DateTime> Createddate { get; set; }
        public string CompanyName { get; set; }
        public string city { get; set; }
        public Nullable<bool> Married { get; set; }
    }

查看: -

    @model IEnumerable< MVC6_Grid_with_filters.Models.SchemeMaster>
    @using NonFactors.Mvc.Grid;
    @{
        Layout = null;
    }

    < link href="@Url.Content("~/Content/MvcGrid/mvc-grid.css")" rel="stylesheet" />
    < script src="~/Scripts/jquery-2.1.4.min.js">< /script>
    < script src="~/Scripts/MvcGrid/mvc-grid.js" type="text/javascript">< /script>

    @(Html
    .Grid(Model)
    .Build(columns =>
    {
        columns.Add(c => c.SchemeID).Titled("SchemeID");
        columns.Add(c => c.SchemeName).Titled("SchemeName");
        columns.Add(c => c.city).Titled("City Name");
        columns.Add(o => o.CompanyName).Titled("Company Name");
        columns.Add(c => c.Createddate, "Createddate").Titled("Date");
        columns.Add(c => c.Married).Titled("Married");
    })
    .Filterable()
    .Sortable()
    .Pageable()
    )
    <script>
        $('.mvc-grid').mvcgrid();
    </script>

2 个答案:

答案 0 :(得分:1)

我的解决方法是从nuget下载mvc5.grid而不是6

答案 1 :(得分:0)

尝试将@using NonFactors.Mvc.Grid;添加到_ViewImports.cshtml

mvc6-grid.azurewebsites.net/installation