Kendo 网格 MVC - 数据源错误
Kendo Grid MVC - DataSource Error
我刚刚开始学习 Kendo UI MVC,并且 运行 正在处理以下问题。这是我的代码:
@(Html.Kendo().Grid<JeffreysOnline.Entities.Customer>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.FirstName);
columns.Bound(p => p.LastName);
columns.Bound(p => p.Address);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.ProductID))
.Create(update => update.Action("EditingInline_Create", "Grid"))
.Read(read => read.Action("EditingInline_Read", "Grid"))
.Update(update => update.Action("EditingInline_Update", "Grid"))
.Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
)
)
我收到以下错误,第 23 行突出显示。
Compiler Error Message: CS1660: Cannot convert lambda expression to type 'string' because it is not a delegate type
Line 21: .Scrollable()
Line 22: .HtmlAttributes(new { style = "height:550px;" })
Line 23: .DataSource(dataSource => dataSource
Line 24: .Ajax()
Line 25: .PageSize(20)
它似乎不喜欢 'dataSource' 但我不知道它会期待什么。
如果 ProductId 不是您型号的 属性,这可能会导致错误。
您似乎几乎直接从位于 http://demos.telerik.com/aspnet-mvc/grid/editing-inline 的 telerik 内联编辑教程页面中获取了该示例,因此请尝试调整它指向数据源中模型的列。像这样:
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.RandyMindersActualIdColumnProperty)) // Here is the change
.Create(update => update.Action("EditingInline_Create", "Grid"))
.Read(read => read.Action("EditingInline_Read", "Grid"))
.Update(update => update.Action("EditingInline_Update", "Grid"))
.Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
)
我刚刚开始学习 Kendo UI MVC,并且 运行 正在处理以下问题。这是我的代码:
@(Html.Kendo().Grid<JeffreysOnline.Entities.Customer>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.FirstName);
columns.Bound(p => p.LastName);
columns.Bound(p => p.Address);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(250);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.ProductID))
.Create(update => update.Action("EditingInline_Create", "Grid"))
.Read(read => read.Action("EditingInline_Read", "Grid"))
.Update(update => update.Action("EditingInline_Update", "Grid"))
.Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
)
)
我收到以下错误,第 23 行突出显示。
Compiler Error Message: CS1660: Cannot convert lambda expression to type 'string' because it is not a delegate type
Line 21: .Scrollable()
Line 22: .HtmlAttributes(new { style = "height:550px;" })
Line 23: .DataSource(dataSource => dataSource
Line 24: .Ajax()
Line 25: .PageSize(20)
它似乎不喜欢 'dataSource' 但我不知道它会期待什么。
如果 ProductId 不是您型号的 属性,这可能会导致错误。
您似乎几乎直接从位于 http://demos.telerik.com/aspnet-mvc/grid/editing-inline 的 telerik 内联编辑教程页面中获取了该示例,因此请尝试调整它指向数据源中模型的列。像这样:
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.RandyMindersActualIdColumnProperty)) // Here is the change
.Create(update => update.Action("EditingInline_Create", "Grid"))
.Read(read => read.Action("EditingInline_Read", "Grid"))
.Update(update => update.Action("EditingInline_Update", "Grid"))
.Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
)