Kendo Grid行没有显示

时间:2014-03-07 21:28:15

标签: kendo-grid

我使用剃刀包装器有一个非常基本的网格,我预期的3行没有出现。

@(Html.Kendo().Grid<ManageUserViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.UserName);
        columns.Bound(c => c.FirstName);
        columns.Bound(c => c.LastName);
        columns.Bound(c => c.Email);
        columns.Bound(c => c.LastNameFirstLetter).Hidden(true);
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("list", "User"))
    )
)

这是从/ User / list返回的json,我通过jsonLint运行以确保它是有效的。

[{"UserName":"dfeinberg","FirstName":null,"LastName":null,"Email":"daniel.feinberg@rcsg.com","Password":null,"Roles":[],"LastNameFirstLetter":""},{"UserName":"jmarley","FirstName":"Jacob","LastName":"Marley","Email":"ebuntom@gmail.com","Password":null,"Roles":[{"Id":"9a0af7ad-e38f-4300-a49e-1051dc18c8e4","Name":"Administrator","Checked":false}],"LastNameFirstLetter":"M"},{"UserName":"tcoakley","FirstName":"Tom","LastName":"Coakley","Email":"tom.coakley@redcedarsolutionsgroup.com","Password":null,"Roles":[],"LastNameFirstLetter":"C"}]

1 个答案:

答案 0 :(得分:0)

这是我愚蠢问题的日子。我的问题是没有理解从控制器返回数据源的正确方法。这是我纠正的控制器方法。

public ActionResult List([DataSourceRequest]DataSourceRequest request)
{
    List<AspNetUser> users = SdContext.AspNetUser.ToList();
    var models = UserAssembler.GetManageUserViewModels(users);

    return Json(models.ToDataSourceResult(request));
}