dynamic Grid

2 posts, 0 answers
  1. FranckSix
    FranckSix avatar
    19 posts
    Member since:
    Feb 2011

    Posted 07 Jan 2020 Link to this post

    Hi all,

    I am trying to make an HtmlHelper to create sub grids by passing an ISubGridBuilder which will contain the construction detail of my sub grid.


    public interface ISubGridBuilder
       string ActionName { get; }
       string ControlerName { get; }
       void BuildColumns(GridColumnFactory<dynamic> gcf);
    public static MvcHtmlString SubGridClient(this HtmlHelper html, ISubGridBuilder builder)
       return html.Kendo().Grid<dynamic>()
          .Navigatable(n => n.Enabled(true))
          .Selectable(s => s
          .Columns(gcf =>
          .DataSource(d => d
             .Model(m =>
                m.Field("ParentId", typeof(int));
             .Read(r => r.Action(builder.ActionName, builder.ControlerName, new {Id = "#=ParentId#" }))
          .Pageable(p => p
             .PageSizes(new[] { 3 })
          .Events(e => e.Change("function(e) { onChange(e)}"))

    The problem is that at runtime I get a reference error:

    VM17183:3 Uncaught ReferenceError: ParentId is not defined
        at Object.eval [as tmpl0] (eval at compile (kendo.all.js:234), <anonymous>:3:12352)
        at Object.eval (eval at compile (kendo.all.js:234), <anonymous>:3:185)
        at d (jquery.min.js:2)
        at HTMLAnchorElement.<anonymous> (kendo.all.js:64799)
        at HTMLTableElement.dispatch (jquery.min.js:3)
        at HTMLTableElement.r.handle (jquery.min.js:3)

    How can I add the ParentId parameter on the routeValues for the controller call.

    Thank you!

  2. Tsvetomir
    Tsvetomir avatar
    757 posts

    Posted 09 Jan 2020 Link to this post

    Hi Francis,

    I have investigated the provided code snippets and I have noticed that the ParentID is a field that is available for the detail grid. However, the template is evaluated at the parent-level, therefore, the parent grid does not have such a field. Could you try alternating the declaration as follows:

             .Read(r => r.Action(builder.ActionName, builder.ControlerName, new {Id = "\\#=ParentId\\#" }))

    Let me know in case the issue persists.


    Progress Telerik

    Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
Back to Top