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

How to set the default child template to show?

7 Answers 198 Views
GridView
This is a migrated thread and some comments may be shown as answers.
hosein
Top achievements
Rank 1
hosein asked on 13 Feb 2011, 10:11 AM

Hello

I was looking for a way to set the active (default) child template in hierarchical radGridView programmatically.

but I could not find any property to set that.

Is there a way to do that?

7 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 16 Feb 2011, 01:53 PM
Hi hosein,

Thank you for contacting us. I am not sure that I understand correctly what exactly you want to achieve. Could you please describe in greater detail the desired behavior?

You cannot change the default template, because it does not contain a selected state. The GridViewInfo object contained in the template contains this state. You can change the current GridViewInfo object by setting the CurrentView property. Here is an example:
this.radGridView1.ChildRows[0].IsExpanded = true;
this.radGridView1.MasterTemplate.CurrentView = ((GridViewHierarchyRowInfo)this.radGridView1.ChildRows[0]).ActiveView;
this.radGridView1.ChildRows[0].ChildRows[0].IsCurrent = true;

I hope it helps. Should you have any further questions, do not hesitate to ask.

Greetings,
Jack
the Telerik team
Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
0
hosein
Top achievements
Rank 1
answered on 16 Feb 2011, 09:33 PM

Hello Jack

thanks for answer.

I have a master GridView and Five child Templates(). I want to set the third child template (for example) to show when I expand the master gridview rows. It always shows the first child template while expanding rows.

is there any way to do that?

regards

0
Richard Slade
Top achievements
Rank 2
answered on 16 Feb 2011, 09:43 PM
Hello,

As far as I know this is not possible because as Jack explained. it doesnt have a selected state. You could however change the order in which you define your relations to make the one that you want the intial (selected) tab
Richard
0
hosein
Top achievements
Rank 1
answered on 19 Feb 2011, 09:51 AM
Hello Richard
I was working on it but I could not find a way to programmatically change the order of child templates.
Is there any way to do that?
that code only sets active row of a child template.(it helpful for my problem)

Thanks
0
Richard Slade
Top achievements
Rank 2
answered on 19 Feb 2011, 12:05 PM
Hello Hosein,

I believe that the way to do this would be to remove all child template and re-add them in the order that you need.
Hope you find that helpful
Richard
0
Accepted
Jack
Telerik team
answered on 21 Feb 2011, 03:32 PM
Hello Hosein,

You can change the active tab in grid hierarchy by handling the ChildViewExpanding event. Here is a sample:
void radGridView1_ChildViewExpanding(object sender, ChildViewExpandingEventArgs e)
{
    if (!e.IsExpanded)
    {
        e.ParentRow.ActiveView = e.ParentRow.Views[1];
    }
}

The tab order is determined by the order in which templates are stored in the Templates collection. You can change this order by using the Move method. Consider the following code:
this.radGridView1.Templates.Move(0, 1);

I hope this helps. If you have any other questions, do not hesitate to contact us.

All the best,
Jack
the Telerik team
0
hosein
Top achievements
Rank 1
answered on 23 Feb 2011, 03:25 PM

Hello jack

thank you for answer

that's what I was looking for.

thanks a lot.

Tags
GridView
Asked by
hosein
Top achievements
Rank 1
Answers by
Jack
Telerik team
hosein
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Share this question
or