Child Row taking Parent Data

2 posts, 0 answers
  1. AHM
    AHM avatar
    2 posts
    Member since:
    Jan 2011

    Posted 18 Feb 2013 Link to this post

    Hi,

    I have a hierarchical grid with where the child is displaying data from the parent, I suspect its the way Im binding to the data.

    Parent

    @(Html.Kendo().Grid(Model.CVXElements) // Specify the type of the grid
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.ElementSeqNo).Title("Element ID").Width("100px").ClientTemplate(
            Html.ActionLink("#= ElementSeqNo #", "PUSH", "ElementBuilder", new {url = "~/PagCC/EB_ElementAddEdit.aspx", ID = "#= ElementSeqNo #", cvxCode = Model.CVXCode  }, null).ToString());
       
        columns.Bound(p => p.ElementName).Width("900px");
        columns.Bound(p => p.ElementStatus).Width("100px");
        columns.Bound(p => p.ElementActive).Title("Live").Width("100px");  
        columns.Bound(p => p.ParentElement).HtmlAttributes( new {@style= "display:none"}).HeaderHtmlAttributes(new { @style= "display:none;" });                   
    })
    .ClientDetailTemplateId("ParentElementTemplate")
    .Events(events => events.DataBound("dataBound"))
    .DataSource(dataSource => dataSource
    .Ajax()
    )
    .Events(events => events.DataBound("dataBound"))
    Child
    <script id="ParentElementTemplate" type="text/kendo-tmpl">
        @(Html.Kendo().Grid<ElementBuilder.Models.Elements>(Model.CVXElementParents)
                .Name("ParentGrid")
                .Columns(columns =>
                {
     
                                    columns.Bound(p => p.ElementSeqNo).Title("Element ID").Width("91px")
                                    .ClientTemplate(
                                        Html.ActionLink("#= ElementSeqNo #", "PUSH", "ElementBuilder", new {url = "~/PagCC/EB_ElementAddEdit.aspx", ID = "#= ElementSeqNo #"  }, null).ToString());
                                   
                                    columns.Bound(p => p.ElementName).Width("910px");
                                    columns.Bound(p => p.ElementStatus).Width("100px");
                                    columns.Bound(p => p.ElementActive).Title("Live").Width("88px"); 
                })
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Read(read => read.Action("HierarchyBinding_ParentElements", "ElementBuilder", new { iElemSeqNo = "#=ElementSeqNo#" }))
                )
                .ToClientTemplate()
     
        )
    </script>
    Both grids use the ElementSeqNo field to create a Hyperlink, however as stated, the child is taking the parent element data.

    Any suggestions appreciated.

    Regards
    Ross
  2. Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 20 Feb 2013 Link to this post

    Hi Ross,

    The "#" character needs to be escaped in order for it to be evaluated in the correct context e.g.

    "\\#= ElementSeqNo \\#"
    Also, the Html.ActionLink helper will encode the route parameters so the expression will not be correctly evaluated. In order to add it correctly you should use the approach from this documentation topic.

    Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top