Kendo Grid MVC - DataSource Error

Randy Minder

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.

Dinglemeyer NeverGonnaGiveUUp

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"))
    )

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Kendo UI MVC Grid - DataSource Interfering With Column Template

kendo mvc grid with a custom datasource that has null id rows

Kendo UI Grid MVC dataSource.at(0) undefined with AutoBind = false and after dataSource.Read()

MultiColumn header with Datasource Kendo Grid

Kendo UI MVC Grid with Kendo Window - 500 error

Kendo Vue datasource for Kendo grid with Auth Header

Setting Kendo UI Grid DataSource Read property with Handler in ASP.NET Core MVC with Razor Pages

How to update and reload the datasource of a Kendo UI MVC grid from clientside upon search

assigning Datasource of kendo grid in Javascript part. (Asp.net MVC-Razor Engine)

MVC Kendo Grid Style

Dynamic bind kendo grid dataSource binded to directive

Kendo grid dataSource.filter all columns

Kendo Grid datasource refresh does not work in IE

Kendo UI Grid, sorting datasource groups

kendo Grid DataSource with OData format = json

Different Kendo grid Datasource when grouping applied

Getting Kendo Grid from its DataSource

How to filter already filtered datasource in Kendo grid

Get datasource of child grid in Kendo using angular

how to check if kendo grid datasource is empty

How to use SignalR Datasource with Kendo Grid

Kendo Grid Mvc - Cannot be shown custom error message on view page

MVC Kendo Combobox set value from the DataSource

Set datasouce of child grid using datasource of parent grid in Kendo UI

Using Kendo Grid in MVC with AJAX

Sorting on Kendo UI MVC Grid

Adding DropDownList to kendo grid in MVC

Kendo UI MVC Grid Not Updating

MVC Kendo Grid Hyperlink column