Kendo grid throws error

2 posts, 0 answers
  1. Byron
    Byron avatar
    1 posts
    Member since:
    Aug 2015

    Posted 24 Sep 2015 Link to this post

    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!

     

  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 28 Sep 2015 Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top