Kendo Grid MVC简单绑定到模型

时间:2015-12-02 16:20:05

标签: asp.net-mvc razor kendo-ui kendo-grid kendo-ui-grid

我是MVC的新手并尝试使用将绑定到模型的Kendo Grid生成视图。

我的观点有

@ModelType CDB.GridDetail

 @Code
 Html.Kendo().Grid(Model.GridDetailPersons)() _
    .Name("Grid") _
    .Columns(Sub(c) _
             c.Bound(Function(s) s.PersonID End Function) _
             c.Bound(Function(s) s.Status End Function) _
             c.Bound(Function(s) s.OperationalTeam End Function) End Sub) _
    .Pageable() _
    .Sortable() _
    .ToolBar(Function(t) t.Create() _
             t.Custom().Name("myCustomCommand").Text("custom toolbar button") End Function) _
    .Filterable() _
    .DataSource(Function(d) d.Ajax() _
             .PageSize(200) _
             .ServerOperation(False) End Function) _
    .Render()
End Code

我的模特是

Public Class GridDetail

    Public Property GridDetailPersons As IQueryable(Of Person)
    Public Property Message As String

End Class

Imports System.ComponentModel
Imports System.ComponentModel.DataAnnotations

Public Class Person

    <Required, StringLength(50), DisplayName("Person ID")>
    Public Property PersonID As String

    <DisplayName("Status")>
    Public Property Status As String

    <DisplayName("OPs Support Team")>
    Public Property OperationsTeam As String

End Class

不幸的是,我似乎无法绑定到我的模型我在VS(Model.GridDetailPersons下的波浪线)中出现错误,该错误表明 Class&#39; GridBuilder(Of Person)&# 39;无法编入索引,因为它没有默认属性。

如果我将该行更改为Html.Kendo().Grid(Of Model.GridDetailPersons)(),则错误更改为键入&#39; Model.GridDetailPersons&#39;未定义。

我做错了什么...特别是如果使用razor vb语法,那里很少。

我的网格仅用于显示...不需要编辑,添加或删除。

0 个答案:

没有答案
相关问题