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

radiobutton in datatemplate

2 Answers 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sampath
Top achievements
Rank 1
Sampath asked on 31 Aug 2010, 10:50 AM
Hi Everyone
Thanks IN Advance,
I have a gridview with a radiobutton in a datatemplate, the problem is if i click on any of the radiobutton list in the grid the selected item of the gridview doesnot change as it would happen normally.

Example:
 <telerikGrid:GridViewDataColumn Header="Magnifier" DataMemberBinding="{Binding IsPrimary}" IsReadOnly="True">
                                                <telerikGrid:GridViewDataColumn.CellTemplate>
                                                    <DataTemplate>
                                                        <RadioButton HorizontalAlignment="Center" IsChecked="{Binding IsMagnifier}" x:Name="radMagnifier" GroupName="magnifier" Checked="radMagnifier_Checked" />
                                                    </DataTemplate>
                                                </telerikGrid:GridViewDataColumn.CellTemplate>
                                            </telerikGrid:GridViewDataColumn>                                            
                                        </telerikGrid:RadGridView.Columns>

If there are ten rows populated if am clicking on the third row then the selectedItem object of the grid doesnot change to the third row, Can anyone helpme out in this case.

Thanks 
Sampath Kumar



2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 31 Aug 2010, 12:21 PM
Hello Sampath,

In order to make the row selected on clicking on the corresponding RadioButton, you need to use the extension method ParentOfType (you need to add reference to the Telerik.Windows.Controls assembly) and get the GridViewRow.
For example:

private void radMagnifier_Checked(object sender, RoutedEventArgs e)
        {
            RadioButton radioButton = e.OriginalSource as RadioButton;
            GridViewRow row = radioButton.ParentOfType<GridViewRow>();
            if(row != null)
            {
                row.IsSelected = true;
            }          
        }

 

Sincerely yours,
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
0
Sampath
Top achievements
Rank 1
answered on 01 Sep 2010, 01:40 AM
Hi Maya,
thanks now able to get the selecteitem.............

Thanks & Regards

Sampath
Tags
GridView
Asked by
Sampath
Top achievements
Rank 1
Answers by
Maya
Telerik team
Sampath
Top achievements
Rank 1
Share this question
or