简体   繁体   English

Gridmvccore 没有在表中显示任何数据?

[英]Gridmvccore not showing any data in table?

I am using Nonfactors.Grid.Mvc(6.2.4) and trying to show data in table.我正在使用Nonfactors.Grid.Mvc(6.2.4)并尝试在表格中显示数据。 I have also included styles and js file in layout as well, But data is not showing, even table is now showing.我还在布局中包含stylesjs文件,但是没有显示数据,甚至显示了表格。

View看法

@using NonFactors.Mvc.Grid
@model IQueryable<Student>
@{

ViewBag.Title = "Students List";
 }
    <div class="panel">

        <div class="panel-body">
            @(Html
 .Grid(Model)
 .Build(columns =>
 {
     columns.Add(model => model.Name).Titled("Name");
     columns.Add(model => model.Address).Titled("Surname");
     columns.Add(model => model.Email).Titled("Marital status");

     columns.Add(model => model.GPA).Titled("Age");
     columns.Add(model => model.Major).Titled("Birthday");
     columns.Add(model => model.Minor).Titled("Employed");
 })
 .Empty("No data found")
 .Filterable()
 .Sortable()
 .Pageable()
 )
        </div>

Controller method Controller 方法

   [HttpGet]
    public ViewResult LoadStudents()
    {
        List<Student> students = (from Student in this.Context.Students
                                  select Student).ToList();
        var queryable = students.AsQueryable();// i debug and see data is populating in this

        return View(Context.Set<Student>());

    }

I also use inspect element and check console errors but no error showing as well.我还使用检查元素并检查控制台错误,但也没有显示错误。 I have install gridmvc through package manager.我已经通过 package 管理器安装了 gridmvc。 No error showing, even build successfully but no data is showing,没有错误显示,即使构建成功但没有数据显示,

Do you use asp.net core mvc or asp.net mvc?您使用 asp.net 核心 mvc 还是 asp.net mvc?

Nonfactors.Grid.Mvc(6.2.4) is for ASP.NET MVC projects . Nonfactors.Grid.Mvc(6.2.4)适用于 ASP.NET MVC 项目

Make sure the script is correctly referred.确保正确引用了脚本。

If you using asp.net mvc, you can also try Grid.Mvc, it can work on my site:如果你使用 asp.net mvc,你也可以试试 Grid.Mvc,它可以在我的网站上运行:

https://www.codeproject.com/Tips/597253/Using-the-Grid-MVC-in-ASP-NET-MVC https://www.codeproject.com/Tips/597253/Using-the-Grid-MVC-in-ASP-NET-MVC

Result like:结果如下:

在此处输入图像描述

You should following steps in below link: https://aspnet-core-grid.azurewebsites.net/installation您应该按照以下链接中的步骤操作: https://aspnet-core-grid.azurewebsites.net/installation

Consider the steps of the photo while reading.阅读时考虑照片的步骤。

  1. afetr install from nuget, goto your user profile folder and following path.nuget\packages\NonFactors.Grid.Mvc6从 nuget 安装后,转到您的用户配置文件文件夹并遵循 path.nuget\packages\NonFactors.Grid.Mvc6
    in your project you should be have structure same solution explorer(like photo) in photo.在您的项目中,您应该在照片中具有相同的解决方案资源管理器(如照片)。 find files in presented path and copy to created folders.在提供的路径中查找文件并复制到创建的文件夹。
  2. add css and js to your main page (for me: index.html).将 css 和 js 添加到您的主页(对我来说:index.html)。
  3. use grid extensions namespaces (@using NonFactors.Mvc.Grid) in partial view (for me: _indexGrid.html)在部分视图中使用网格扩展命名空间(@using NonFactors.Mvc.Grid)(对我来说:_indexGrid.html)
  4. and the end add below code to script tag, after included mvc-grid.js最后在包含 mvc-grid.js 后将以下代码添加到脚本标记

 document.querySelectorAll(".mvc-grid").forEach(element => new MvcGrid(element));

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM