我最近开始将Kendo UI整合到我的项目中。我有一个强类型视图,并希望将Kendo网格绑定到视图上的相应视图模型:
@Model IEnumerable(Of IMS_2.Models.expenseclaims)
@Code
ViewData("Title") = "Index"
End Code
<h2>Index</h2>
<div>
@code
Html.Kendo().Grid(Model).Name("ExpenseClaims") _
.Columns(Sub(c)
c.Bound(Function(x) x.ClaimDate).Width(140)
c.Bound(Function(x) x.Title).Width(190)
c.Bound(Function(x) x.Company)
End Sub)
end code
执行代码时,代码在Grid语句处停止,但有异常:
方法调用失败,因为&#39;公共功能 列(配置器为 System.Action`1 [[Kendo.Mvc.UI.Fluent.GridColumnFactory(中 GridColumnFactory(of expenseclaims)))As Kendo.Mvc.UI.Fluent.GridBuilder(费用索赔)&#39;不能叫 有这些论点:
参数匹配参数&#39;配置器&#39;无法转换为&#39; VB $ AnonymousDelegate_2(Of Object)&#39; to&#39; Action(Of GridColumnFactory(of expenseclaims))&#39;。
...作为一个相对新手让我有些困惑。我的代码(我认为)是我在c#中看到的其他示例的直接翻译(参见http://telerikhelper.net/2012/10/26/using-kendo-grid-in-asp-net-mvc-4-0/)
Expenseclaims由EF模板生成,定义为:
Partial Public Class expenseclaims
Public Property id As Long
Public Property Title As String
Public Property ClaimDate As Nullable(Of Date)
Public Property Creator As Nullable(Of Long)
Public Property Company As Long
Public Property AdvanceOffset As Nullable(Of Decimal)
Public Overridable Property expenselines As ICollection(Of expenselines) = New HashSet(Of expenselines)
Public Overridable Property companies As companies
End Class
这是我难倒的地方......感谢任何帮助。
答案 0 :(得分:1)
将@Model更改为VB.NET的@ModelType,因为@Model用于C#。
@ModelType IEnumerable(Of IMS_2.Models.expenseclaims)