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

RowDetail Question

4 Answers 87 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 09 Apr 2010, 03:07 PM
I'm using a RadGridView with a custom RowDetail template that contains buttons for performing editing functions.  I want to be able to call a function that is located within the XAML that contains the parent grid to let it know that some editing has been done and completed.

Is there a way to call functions or modify properties in the parent grid from within the RowDetail template button click handlers?

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 09 Apr 2010, 03:21 PM
Hi Lee Weisenberger,

From within your row details control, you can find the parent grid with the ParentOfType<RadGridView>() extension method and do anything to it. The extension method is in the Telerik.Windows.Controls namespace.

Let me know if there are problems.

Greetings,
Ross
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Lee
Top achievements
Rank 1
answered on 09 Apr 2010, 03:36 PM
I'm sorry, I misspoke when I said I wanted to access a function within the XAML.  I meant to say that I want to access a function within the codebehind for the XAML.

I have a public helper function in the MainPage.xaml.cs that is used to make some updates to private variables and then post those changes to a database.  Is there a way to call the public helper function from the RowDetails template codebehind?

Thanks.
0
Accepted
Rossen Hristov
Telerik team
answered on 09 Apr 2010, 03:45 PM
Hi Lee Weisenberger,

The "function within the codebehind for the XAML" is a member of the user control that RadGridView is inside. So find this top-level user control with the ParentOfType<T> method. This is the control that owns the methods that you are talking about. Then execute them:

var mainWindow = this.ParentOfType<Window1>();
mainWindow.DoSomething();

I hope this helps.

Regards,
Ross
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Lee
Top achievements
Rank 1
answered on 09 Apr 2010, 04:33 PM
Thanks Ross!  That's what I was looking for.

I did have to make one change to code to get it to work from within the codebehind of the RowDetail template.

In my case, I needed use the following code:

var parentGrid = this.ParentOfType<RadGridView>(); // Parent grid for the RowDetail 
var mainWindow = parentGrid.ParentOfType<Window1>(); // this.ParentOfType<Window1>() returns null, use parentGrid instead of "this" keyword 
mainWindow.DoSomething();  

Thanks again.
Tags
GridView
Asked by
Lee
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Lee
Top achievements
Rank 1
Share this question
or