This is a migrated thread and some comments may be shown as answers.

Kendo grid throws error

1 Answer 290 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Byron
Top achievements
Rank 1
Byron asked on 24 Sep 2015, 01:47 PM

I have a grid defined thusly: 

@Model VendorManagement.Web.Models.RiskExposureViewModel
@using Kendo.Mvc.UI

@(Html.Kendo().Grid(Model.RiskMatrixExposureList)

     .Name("grdRiskMatrix")
     .Columns(columns =>
     {
                                columns.Bound(c => c.RiskUnit).Title("Risk Unit");
                                columns.Bound(c => c.RiskCategory).Title("Risk Category");
                                columns.Bound(c => c.RiskDescription).Title("Short Description");
                            })
                            .Read(read => read.Action("BindRiskMatrixGrid", "Risk"))
                            .Pageable()
)

RiskMatrixExposureList is a List<RiskMatrixExposure>. The grid as defined is throwing the following error in Razor:

"Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type"

 I have the namespace defined in Views/web.config:

 <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
        <add namespace="VendorManagement.Web" />
        <add namespace="Kendo.Mvc.UI" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

 

Thanks for they help!

 

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 28 Sep 2015, 07:43 AM

Hello Byron,

 

The casing for model directive is incorrect - `@Model` it should be with lower `m`. I've attached a runnable example.

 

Regards,
Nikolay Rusev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Byron
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or