This is a migrated thread and some comments may be shown as answers.
dynamic Grid
1 Answer 46 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
FranckSix asked on 07 Jan 2020, 04:42 PM

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!

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 09 Jan 2020, 12:48 PM

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.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question