I'm new to KendoUI, and I created a grid in a view to list all instances of my model (StopLocation) and it works fine, except when adding the .Selectable() line to enable multiple selection, I get an error: "There is no DataSource Model Id property specified.". Anybody knows how to define id for this grid? Or is there something wrong with .Selectable() syntax below?
@( Html.Kendo().Grid((IEnumerable<
Route.StopLocation
>)ViewData["Stops"])
.Name("selectedStops")
.Columns(columns =>
{
columns.Bound(p => p.StopNo).Title("Stop No.");
columns.Bound(p => p.Id).Title("ID");
columns.Bound(p => p.StopLocation).Title("Stop Location");
})
// .Selectable causes NotSupportedException: There is no DataSource Model Id property specified.
.Selectable(s => s.Mode(GridSelectionMode.Multiple))
)
Thanks in advance.
13 Answers, 1 is accepted

Just ran into the same issue and I found the solution in the serverediting example for the grid.
I changed my markup by adding the .Datasource section which has the missing model.ID referred to by the error message.
@model IEnumerable<
TestClass.Models.CompanyModel
>
@(Html.Kendo().Grid(Model)
.Name("Grid")
.HtmlAttributes(new { style = "border: 0;" })
.Columns(columns =>
{
columns.Bound(p => p.CompanyID).Groupable(false);
columns.Bound(p => p.Company);
})
.Sortable()
.Filterable()
.Navigatable()
.Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(p => p.CompanyID))
)
)





It would be nice if there was a post from 2017 as well.
Regards,
Konstantin Dikov
Progress Telerik


Worked 3 years ago, worked for me today!
Thanks!



Hello Ann,
To define the model for a Kendo UI DataSource when the unique identifier is nested inside your data structure, you should specify the full property path using dot notation in the model.id
field.
Proper Syntax for Nested ID Property
If your data structure looks like this:
{
"Id": {
"Information": {
"DataTable": {
"TableId": 123
}
}
},
// other properties...
}
You should configure your DataSource schema as follows:
schema: {
model: {
id: "Id.Information.DataTable.TableId",
fields: {
// Define other fields here as needed
}
}
}
This tells the DataSource to use the TableId
inside the nested object as the unique identifier.
MVC Wrapper Example
For the MVC wrappers, the syntax is similar:
.Model(model => {
model.Id(p => p.Id.Information.DataTable.TableId);
// Define other fields here
})
Regards,
Neli
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.