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

Selective expansion of rows involving hierarchical data

1 Answer 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark Nalevanko
Top achievements
Rank 1
Mark Nalevanko asked on 30 Nov 2009, 10:49 PM
Hello,

I am testing out the RadGridView control and noticed when setting up a relationship for hierarchical data display in the control that once I add a row programmatically to the child template's data source that all rows on the main/parent template will expand out when clicking on the + icon for the row even though not all rows have any linked child rows. For my purposes, I would like to disallow the expanding of rows if there's nothing to show as in many cases there will only be a few (if any) rows with child rows linked up. Is this possible? Is there an event I should cancel? Or a way to disable/make invisible the + icon for rows that have no child rows?

Thanks,
Mark

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 01 Dec 2009, 08:44 AM
Hi Mark Nalevanko,

Please take a look at the following KB article. It describes how to hide the expand/collapse image when it is not needed. You can also disable the expansion of a child view by handling ChildViewExpanding event:

void radGridView1_ChildViewExpanding(object sender, ChildViewExpandingEventArgs e)
{
    GridViewRowInfo[] rows = e.CellElement.RowInfo.ViewTemplate.ChildGridViewTemplates[0].GetChildRows(e.CellElement.RowInfo);
    e.Cancel = rows == null || rows.Length == 0; 
}

I hope this helps.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Mark Nalevanko
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or