Problem:
In my application I am displaying data in grid. I also want a radio button to be inserted in 1 st column. On the selection of that radio button new pop-up screen should appear having details of the selected row.
I am using Telerik:RadGridView to display data . I am able to fetch the data and display.
I am getting around 4000 records fetched, now when i select a radio button and scroll down the selected row is deselected and some other random row gets selected.Sometimes no rows gets selected.
Approach followed:
I have followed following approach using virtualization
Inside my RadGridView i worte
VirtualizingStackPanel.IsVirtualizing
="True"
ScrollMode="RealTime"
VirtualizingStackPanel.VirtualizationMode="Recycling"
ScrollViewer.IsDeferredScrollingEnabled="True"
and
<telerik:GridViewDataColumn Header="" Width="35" DataMemberBinding="{Binding IsSelected, Mode=TwoWay}">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<RadioButton Click="radEditGroup_Click" HorizontalAlignment="Center" Checked="radEditGroup_Checked" IsChecked="{Binding Path=IsSelected, Mode=TwoWay}" x:Name="radEditGroup" GroupName="Groups" />
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
In .cs file for Checked ="radEditGroup_Checked" i looped through groups and deselected the radio buttons and displayed last checked button value.
private
void radEditGroup_Checked(object sender, RoutedEventArgs e)
{
try
{
ClearMessage();
if ((sender as RadioButton) != null &&
((sender
as RadioButton).DataContext as Groups) != null)
{
var lobjSelectedGroups = from lobGroup in _Groups
where lobGroup.IsSelected == true
select lobGroup;
if (lobjSelectedGroups != null)
{
foreach (Groups lobGroup in lobjSelectedGroups)
{
lobGroup.IsSelected =
false;
}
}
this._intGroupID = ((sender as RadioButton).DataContext as Groups).FUNCTION_GRP_ID;
this._intFunctionId = ((sender as RadioButton).DataContext as Groups).Function_Id;
(sender
as RadioButton).Checked -= radEditGroup_Checked;
(sender
as RadioButton).IsChecked = true;
(sender
as RadioButton).Checked += radEditGroup_Checked;
}
}
catch (Exception objEx)
{
ErrorHandling.CatchAllExceptions(objEx);
}
}
Issue facing:
When i am selecting the radio button and scrolling down Checked event gets called and slected row gets deselected.
How can i ensure that the radio button which is checked remain same even when i scoll up and down.