MVC 6 - Nested Grids

2 posts, 0 answers
  1. Jako
    Jako avatar
    107 posts
    Member since:
    Apr 2012

    Posted 22 Apr 2016 Link to this post

    Hi everyone, I have a .Net Core/MVC6 application. I get all the Kendo controls to render using the .Deferred() option, but I can't get the ClientTemplate Grids to work? Here is the code

    [code]

    @(Html.Kendo().Grid<UserViewModel>()
    .Name("UserGrid")
    .Columns(columns =>
    {
    columns.Bound(u => u.FirstName);
    columns.Bound(u => u.LastName);
    columns.Bound(u => u.Email);
    })
    .ClientDetailTemplateId("userOrders")
    .Sortable()
    .Pageable()
    .Filterable()
    .DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(30)
    .Read(read => read.Action("UserGrid_Read", "Admin"))
    )
    .Events(events => events.DataBound("userGridBind"))
    .Deferred()
    )

    <script id="userOrders" type="text/kendo-tmpl">
        @(Html.Kendo().Grid<UserOrderViewModel>()
                .Name("UserOrders_#=UserId#")
                .Columns(columns =>
                {
                    columns.Bound(o => o.OrderVat);
                    columns.Bound(o => o.OrderTotal);
                })
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(10)
                    .Read(read => read.Action("UserGrid_Orders", "Admin", new { userId = "#=UserId#" }))
                )
                .Pageable()
                .Deferred()
                .ToClientTemplate()
        )
    </script>

    [/code]

    I receive a Syntax error, unrecognized expression: #UserOrders_#=UserId#

    I have tried remove the deferred, then it doesn't render at all. I have also tried using \\#=UserId\\# but no change.

    How do we get it to work using .Net Core/MVC6 and the deferred options?

    Thank you.

  2. Jako
    Jako avatar
    107 posts
    Member since:
    Apr 2012

    Posted 22 Apr 2016 in reply to Jako Link to this post

    Found the problem.

     

    I had a [Display(Name = "Order #")] attribute in my view model that was causing the problems...

Back to Top