This is a migrated thread and some comments may be shown as answers.

Child Row taking Parent Data

1 Answer 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aetna
Top achievements
Rank 1
Aetna asked on 18 Feb 2013, 01:57 PM
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

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 20 Feb 2013, 12:27 PM
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!
Tags
Grid
Asked by
Aetna
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or