Premium forums

There is no DataSource Model Id property specified.

  • Michel
    Michel avatar

    06 Jul 2012 (Link to this post)

    Hi,
    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.
  • Answered MattL
    MattL avatar

    07 Jul 2012 (Link to this post)

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

Read FAQ or see Kendo UI in action!

Launch Demos