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

How do you only show [+] hierarchy for select rows?

1 Answer 41 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 06 Nov 2014, 04:25 PM
I want to programmatically tell the grid when to show the [+] hierarchy expand button.  Can this be done or do all the rows have to have this enabled?

I have a databound master and a load-on-demand child.  My problem is that not all rows make sense to have this template shown.  Below is how I am approaching this now. 

GridViewTemplate template = new GridViewTemplate();
 template.Columns.Add(new GridViewTextBoxColumn("Account"));
template.Columns.Add(new GridViewTextBoxColumn("CRM Opp ID"));
 gvAttainment.MasterTemplate.Templates.Add(template);

template.HierarchyDataProvider = new GridViewEventDataProvider(template);
 this.gvAttainment.RowSourceNeeded += new GridViewRowSourceNeededEventHandler(gvAttainment_RowSourceNeeded);

...

void gvAttainment_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
{
            
            switch (e.ParentRow.HierarchyLevel)
{

case 0:
                        //Query DB for data and display here
                        GridViewRowInfo row = e.Template.Rows.NewRow();
                        row.Cells["Account"].Value = from DB

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 10 Nov 2014, 12:09 PM
Hello Rob,

Thank you for writing.

You can use the approach from the following article: Hide expand/collapse image in hierarchical RadGridView. You should only modify the IsExpandable method according to your criteria (it won't work with load on demand).

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Rob
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or