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

Group Radio button not functioning proper in Grid

1 Answer 147 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vinod
Top achievements
Rank 1
Vinod asked on 26 Dec 2011, 10:32 AM

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.

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 26 Dec 2011, 05:09 PM
Hello Vinod Sharma,

I am trying to reproduce the problem. However  the pieces of code pasted here are not complete. 
Can you please attach the original files . A runnable project would be also highly appreciated as I could implement a fix for you directly inside and get the updated project back to you.

*To be able to attach a zip with the files you will need to open a support ticket . Please refer this thread Id (496058) in case you do so .

Regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Vinod
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or