C# MVC中的Kindo网格正在显示原始数据

C# MVC中的Kindo网格正在显示原始数据,c#,asp.net-mvc,kendo-ui,kendo-grid,kendo-asp.net-mvc,C#,Asp.net Mvc,Kendo Ui,Kendo Grid,Kendo Asp.net Mvc,我是剑道新手,正在学习如何将其与MVC集成并在网格中显示数据 我的控制器 [HttpGet] public ActionResult StudentList([DataSourceRequest]DataSourceRequest request) { DataSourceResult result = _acc.GetStudent(StudId).ToDataSourceResult(request, model => new StudentModel

我是剑道新手,正在学习如何将其与MVC集成并在网格中显示数据

我的控制器

[HttpGet]
public ActionResult StudentList([DataSourceRequest]DataSourceRequest request)
{
    DataSourceResult result = 
    _acc.GetStudent(StudId).ToDataSourceResult(request,
        model => new StudentModel
        {
            ID = model.ID,
            StudId = model.StudId,
            Name= model.Name,
            Email= model.FullName,
            custEmail = model.Email
        });


        return Json(result, JsonRequestBehavior.AllowGet);
}
我的看法

@(Html.Kendo().Grid<Models.StudentModel>()
                .Name("grid")
                .Columns(columns =>
                {
                    columns.Bound(c => c.StudId);
                    columns.Bound(c => c.Name);
                    columns.Bound(c => c.Email);
                })
                     .Pageable()
                     .Sortable()
                     .Filterable()
                     .Scrollable(scr => scr.Height(550))
                     .DataSource(dataSource => dataSource
                     .Ajax()
                     .Read(read => read.Action("StudList", "Student"))
                     .ServerOperation(false)
  )
)
我在浏览器中得到的输出看起来像

{数据:[{ID:1102,StudId:4006,姓名:Adam Lyon,电子邮件:alyon@regionofwaterloo.ca


有人知道为什么数据没有以网格形式格式化吗?

如果直接链接到EmployeeList操作,则会出现这种行为-该操作只应由网格调用。如果视图名称为say Index,则需要另一个操作:

public ActionResult Index()
{
    return View();
}
然后在代码中链接到:

@Html.ActionLink("Employee List", "Index", "Employee")
现在视图将加载,剑道网格将呈现,然后调用EmployeeList操作填充网格


请参阅剑道示例控制器。它有一个操作来加载带有网格的视图,然后网格将通过AJAX调用CRUD操作。

您是否收到控制台错误?您的代码缺少数据源的关闭参数…数据源已经关闭,它在下面,没有错误,所有数据都来了,但格式不正确,我希望它在G中rid,但请看上面的输出。对不起,我应该在哪里包含代码行@Html.ActionLinkEmployee List,Index,Employee?请提供帮助,我们可以如何使其工作。我已经创建了一个单独的索引视图,并包含了上述操作。现在是500-内部服务器错误。您可以从菜单调用索引控制器操作。\u Layout,主页上的链接等。如果您遇到500错误服务器错误,很可能是在您的读取操作中。因此,设置一个调试点,看看您是否遇到了错误。此外,我给出的操作链接只是一个示例。您的实际链接将取决于您的控制器名称。在本例中,控制器将是EmployeeController.Use语法@Html.ActionLinkLabel、ActionName、ControllerName。