This question is locked. New answers and comments are not allowed.
Keith Stephens
Top achievements
Rank 1
Keith Stephens
asked on 10 Sep 2010, 03:28 PM
Hello all,
I have a gridview with another gridview in it. Eventhough the information is parent child related I am not doing any kind of "ParentPropertyName=?" stuff, I am just doing an ItemsSource binding to an object within the parent object. (hope that makes sense.)
My problem/question. When I try and delete a child row it goes and calls it's deleting events, but it also calls the parents deleting events. Is there a way to stop this?
Thanks,
KS
I have a gridview with another gridview in it. Eventhough the information is parent child related I am not doing any kind of "ParentPropertyName=?" stuff, I am just doing an ItemsSource binding to an object within the parent object. (hope that makes sense.)
My problem/question. When I try and delete a child row it goes and calls it's deleting events, but it also calls the parents deleting events. Is there a way to stop this?
Thanks,
KS
3 Answers, 1 is accepted
0
Hello Keith Stephens,
Please, excuse us for the late reply.
The described behavior is correct because Deleting event is a Routed event. So, when is called for the child grid, the parent grid Deleting event is also listening for it. In this case, you do not need Deleting event for the Child grid. You can directly subscribe to Deleting event for the Parent grid and there to listen for deleting items from Child grid:
I hope this helps.
All the best,
Yordanka
the Telerik team
Please, excuse us for the late reply.
The described behavior is correct because Deleting event is a Routed event. So, when is called for the child grid, the parent grid Deleting event is also listening for it. In this case, you do not need Deleting event for the Child grid. You can directly subscribe to Deleting event for the Parent grid and there to listen for deleting items from Child grid:
private void clubsGrid_Deleting(object sender, GridViewDeletingEventArgs e) { if (e.OriginalSource == this.clubsGrid) { //parent } else { // child } }I hope this helps.
All the best,
Yordanka
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
Keith Stephens
Top achievements
Rank 1
answered on 16 Sep 2010, 01:32 PM
That's great thanks, as a work around I was using a flag variable.
But now I have gotten additional requirements that might complicate things alittle.
Can you have a gridview with a 2 child grids at the same level.
Example. Gridview1
Gridview2
Grridview3
Rather than:
Gridview1
Gridview2
Gridview3
If so can you maybe supply a demo of this, and how a delete might work.
Thanks again,
KS.
But now I have gotten additional requirements that might complicate things alittle.
Can you have a gridview with a 2 child grids at the same level.
Example. Gridview1
Gridview2
Grridview3
Rather than:
Gridview1
Gridview2
Gridview3
If so can you maybe supply a demo of this, and how a delete might work.
Thanks again,
KS.
0
Accepted
Hi Keith Stephens,
Thus you can handle each child's Deleting event as follows:
In that way the Deleting event of the parent grid will not be raised.
I am sending you a sample project that illustrates the proposed solution.
Maya
the Telerik team
You may define your HierarchyChildTemplate as follows:
<telerik:RadGridView.HierarchyChildTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <telerik:RadGridView x:Name="childGrid1" Grid.Row="0" Deleting="childGrid1_Deleting" /> <telerik:RadGridView x:Name="childGrid2"
Grid.Row="1" Deleting="childGrid2_Deleting"/>
</Grid> </DataTemplate></telerik:RadGridView.HierarchyChildTemplate>Thus you can handle each child's Deleting event as follows:
private void childGrid1_Deleting(object sender, GridViewDeletingEventArgs e){ //custom logic implementation e.Handled = true;}In that way the Deleting event of the parent grid will not be raised.
I am sending you a sample project that illustrates the proposed solution.
Maya
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