Reputation: 48522
I'm just starting to learn Kendo UI MVC and am running across the following issue. Here is my code:
@(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"))
)
)
I'm getting the following error, with line 23 highlighted.
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)
It appears it doesn't like 'dataSource' but I have no clue what it would be expecting.
Upvotes: 0
Views: 1638
Reputation: 712
If ProductId is not a property of your model, this may be causing the error.
It appears you took the example almost directly from telerik's inline editing tutorial page at: http://demos.telerik.com/aspnet-mvc/grid/editing-inline, so try adjusting the column this is pointing to for your Model within the data source. like so:
.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"))
)
Upvotes: 1