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

Parent row collapses when changing detail grid's page

1 Answer 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sergei
Top achievements
Rank 1
Sergei asked on 17 Jun 2013, 04:07 PM
Hi.

I use two-level hierarchical grid with asp.net helpers (server binding) and everything goes right, except one small issue. Changing the page of the detail grid causes its parent row to collapse once the data is reloaded. Same goes for sorting rows of the detail grid.

Grid code: http://pastebin.com/Wyrgf1yb

Is that a limitation of server binding? Or I'm using the grid helper wrong?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 19 Jun 2013, 11:36 AM
Hello Sergei,

In server binding mode, the page is reloaded when performing paging so that the new data can be rendered. Thus the Grid will be rendered in its initial state(with collapsed detail rows) by default. In order to persist the expanded row I can suggest to send the parent ID with the detail Grid request and use the RowAction callback to expand the row based on the sent ID e.g.

@(Html.Kendo().Grid(Model)
    .Name("grid")
    ...
    .RowAction(row =>
    {
        if (row.DataItem.Id.ToString() == Request.QueryString["rowID"])
        {
            row.DetailRow.Expanded = true;
        }
    })
    .DetailTemplate(@<text>
        @(Html.Kendo().Grid(item.PropertyValues)
            ...
            .DataSource(dataSource => dataSource
                .Server()
                .Read(read => read.Action("action", "controller", new { rowID = item.Id }))
            )
            .Pageable()
        )
    </text>)
)
Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Sergei
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or