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

selection change event getting fired unnessariarly

1 Answer 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kumar p
Top achievements
Rank 1
kumar p asked on 09 Jun 2010, 08:50 AM
hi
 here i  am  using  nested  datagrid this is design   of my xaml code

 

 

 

 

 

<

 

 

telerik:RadGridView x:Name="RadGrid1" Grid.Row="1" Grid.Column="0" ScrollViewer.HorizontalScrollBarVisibility ="Disabled" AreRowDetailsFrozen="True" BorderThickness="0" CanUserResizeColumns="False" RowHeight="24" ShowGroupPanel="False" RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False" SelectionMode="Extended" RowDetailsVisibilityMode="Collapsed" IsReadOnly="True" AutoGenerateColumns="False" RowDetailsVisibilityChanged="RadGrid1_RowDetailsVisibilityChanged" SelectionChanged="RadGrid1_SelectionChanged" RowLoaded="RadGrid1_RowLoaded" RowUnloaded="RadGrid1_RowUnloaded">

 

 

 

 

<telerik:RadGridView.Columns>

 

 

 

 

<telerik:GridViewDataColumn>

 

 

 

 

<telerik:GridViewDataColumn.CellTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<Button x:Name="myButton"

 

 

 

Click="ExpandLevel1_Click">

 

 

 

 

<Image x:Name="imgLevel1" Source="Images/left_side.png" Stretch="None" />

 

 

 

 

</Button>

 

 

 

 

</DataTemplate>

 

 

 

 

</telerik:GridViewDataColumn.CellTemplate>

 

 

 

 

</telerik:GridViewDataColumn>

 

<telerik:GridViewDataColumn Header="name" Width="*" >

 

 

 

 

<telerik:GridViewDataColumn.CellTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<my:Label Content="{Binding name}" />

 

 

 

 

</DataTemplate>

 

 

 

 

</telerik:GridViewDataColumn.CellTemplate>

 

 

 

 

</telerik:GridViewDataColumn>

 

 

 

 

<telerik:GridViewDataColumn Header="Age" Width="100" >

 

 

 

 

<telerik:GridViewDataColumn.CellTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<my:Label Content="{Binding Age}" />

 

 

 

 

</DataTemplate>

 

 

 

 

</telerik:GridViewDataColumn.CellTemplate>

 

 

 

 

</telerik:GridViewDataColumn>

 

 

 

 

<telerik:RadGridView.RowDetailsTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<StackPanel x:Name="spLevel2" >

 

 

 

 

</StackPanel>

 

 

 

 

</DataTemplate>

 

 

 

 

</telerik:RadGridView.RowDetailsTemplate>

 

 

 

 

</telerik:RadGridView x: name ="RadGrid2" >

 

</

 

 

StackPanel>

 

 

 

 

</DataTemplate>

 

 

 

 

</telerik:RadGridView.RowDetailsTemplate>

 

 

 

 

</telerik:RadGridView>

 


 in grid1  i am finding grid2 then creating vents for teh grid2

 

if

 

 

(RadGrid2 != null)

 

{

RadGrid2.RowDetailsVisibilityChanged +=

 

new EventHandler<GridViewRowDetailsEventArgs>(RadGrid2_RowDetailsVisibilityChanged);

 

RadGrid2.SelectionChanged +=

 

new EventHandler<SelectionChangeEventArgs>(RadGrid2_SelectionChanged);
}

when i click on the row of my second datagrid  only
RadGrid2_SelectionChanged  events  should be  called
but here  even my RadGrid1 (RadGrid1_SelectionChanged) is getting fired
is there any way i can solve this issue.

any help  would be great
thanks.

 

1 Answer, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 09 Jun 2010, 09:52 AM
Hi kumar p,

SelectionChanged is a RoutedEvent and it will travel up the visual tree - if you make a selection in a child grid the parent grid's SelectionChanged event will also be raised. You can use the event arguments (e.OriginalSource) to determine the original source of the selection event and determine how SelectionChanged will be handled.


Kind regards,
Milan
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.
Tags
GridView
Asked by
kumar p
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or