剑道无约束列

时间:2018-03-27 05:46:45

标签: vb.net kendo-grid kendo-asp.net-mvc

我想在这个网格中添加一个自定义列,我尝试了下面的代码中的模板方法,但代码甚至没有编译,我得到了一个错误,我也在下面提供。我想在kendo网格中创建一个自定义列,然后在该列中有一个可点击的链接,它调用一个javascript函数。有可能吗?

@ModelType IEnumerable(Of Gatekeeper.SystemGroupMembers)
@Code
ViewData("Title") = "DisplayMembers"
End Code

@(Html.Kendo().Grid(Model) _
        .Name("SystemGroupMembers") _
        .Columns(Sub(c)
                     c.Bound(Function(p) p.Name)
                     c.Bound(Function(p) p.Class)
                     c.Bound(Function(p) p.ParentName)
                     c.Template(@<text>blah</text>).Title("blah")
                 End Sub) _
.Sortable() _
.DataSource(Sub(c)
                c.Ajax() _
                .ServerOperation(False)
            End Sub)
)

<div>
@Html.ActionLink("Back to List", "DisplayGroups")
</div>

错误:

Compilation Error 
  Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

 Compiler Error Message: BC30201: Expression expected.

Source Error:

Line 8:              .Name("SystemGroupMembers") _
Line 9:              .Columns(Sub(c)
Line 10:                             c.Template(@<text>Click here</text>)
Line 11:                              c.Bound(Function(p) p.Name)
Line 12:                              c.Bound(Function(p) p.Class)

1 个答案:

答案 0 :(得分:0)

在我看到这段代码时,问题是您正在为视图定义模型,然后您还将此模型链接到kendo网格,这是不可能的。这应该是两个独立的模型。我猜你甚至不需要一个模型来渲染网格。您还没有在DataSource定义中定义读取操作。 我不是vb.net开发人员,但我会尝试这样做。如果我的vb语法错误,请纠正我:

@Code
ViewData("Title") = "DisplayMembers"
End Code

@(Html.Kendo().Grid(Of Gatekeeper.SystemGroupMembers) _
        .Name("SystemGroupMembers") _
        .Columns(Sub(c)
                     c.Bound(Function(p) p.Name)
                     c.Bound(Function(p) p.Class)
                     c.Bound(Function(p) p.ParentName)
                     c.Template(@<text>blah</text>).Title("blah")
                 End Sub) _
.Sortable() _
.DataSource(Sub(c)
                c.Ajax() _
              .Read(Function(read) read.Action("SomeAction", "YourController")) _
                .ServerOperation(False)
            End Sub)
)

<div>
@Html.ActionLink("Back to List", "DisplayGroups")
</div>

另请查看此链接:

https://docs.telerik.com/aspnet-mvc/getting-started/vb#grid