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

Child data in hierarchical grid showing on wrong row

1 Answer 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wdudek
Top achievements
Rank 1
wdudek asked on 21 May 2014, 07:49 PM
I've created a hierarchical grid which seemed like it was working properly until I started expanding multiple rows. In the attached screen shots if I click on row 5 it works, but then when I click on row 10 the data comes back under row 5 and row 10 is empty. I can reproduce this with any combination of rows. 

The child grid is defined as follows
<script id="template" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<Ebook2Web.PricingGridSvc.PricingGridDetail >()
            .Name("PricingGridDetail_#PricingGridId#")
            .Columns(columns =>
            {
                columns.Bound(d => d.PricingGridDetailId);
                columns.Bound(d => d.StartPrice);
                columns.Bound(d => d.EndPrice);
                columns.Bound(d => d.Price);
                columns.Bound(d => d.TierId);
                columns.Bound(d => d.ModifiedBy);
                columns.Bound(d => d.ModifiedDate);     
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("CreatePricingGridDetail", "PricingGrid", new { pricingGridId = "#=PricingGridId#" }))
            )
            .ToClientTemplate()
    )
 
</script>

and the controller method as 
public ActionResult CreatePricingGridDetail(int pricingGridId, [DataSourceRequest] DataSourceRequest request)
       {
           var pricingGrid = PricingGrids.SingleOrDefault(x => x.PricingGridId == pricingGridId);
           return Json(pricingGrid.Details.ToDataSourceResult(request));
       }
 I've attached the full files in the zip. This is my second Kendo grid and first hierarchical one so I'd appreciate any help.

Bill

1 Answer, 1 is accepted

Sort by
0
wdudek
Top achievements
Rank 1
answered on 21 May 2014, 07:59 PM
Figured it out, I had a typo and all the child grids had the same id. 

 @(Html.Kendo().Grid<Ebook2Web.PricingGridSvc.PricingGridDetail >()
            .Name("PricingGridDetail_#PricingGridId#")
instead of 
 @(Html.Kendo().Grid<Ebook2Web.PricingGridSvc.PricingGridDetail >()
            .Name("PricingGridDetail_#=PricingGridId#")
Tags
Grid
Asked by
wdudek
Top achievements
Rank 1
Answers by
wdudek
Top achievements
Rank 1
Share this question
or