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


    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.


    @(Html.Kendo().Grid(Model.CVXElements) // Specify the type of the 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;" });                   
    .Events(events => events.DataBound("dataBound"))
    .DataSource(dataSource => dataSource
    .Events(events => events.DataBound("dataBound"))
    <script id="ParentElementTemplate" type="text/kendo-tmpl">
                .Columns(columns =>
                                    columns.Bound(p => p.ElementSeqNo).Title("Element ID").Width("91px")
                                        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
                    .Read(read => read.Action("HierarchyBinding_ParentElements", "ElementBuilder", new { iElemSeqNo = "#=ElementSeqNo#" }))
    Both grids use the ElementSeqNo field to create a Hyperlink, however as stated, the child is taking the parent element data.

    Any suggestions appreciated.

  2. Daniel
    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,
    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