We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to add RadioButton columns in GridDataControl WPF

Hello,

I'm trying the add the RadioButton columns in WPF GridDataControl and couldn't succeed. Is this possible? If so could you please point me to the sample/example available online?
Here is the scenario: I have grid control with multiple columns and I want to add RadioButton for three columns A, B and C and want them mutual exclusive.

Thanks
Mahesh

3 Replies

JG Jai Ganesh S Syncfusion Team September 1, 2016 12:55 PM UTC

Hi Mahesh, 
 
You can add the RadioButton inside the GridDataVisibleColumn’s CellItemTemplate like below, 
 
<syncfusion:GridDataVisibleColumn HeaderText="Checked" MappingName="IsChecked"> 
        <syncfusion:GridDataVisibleColumn.CellItemTemplate> 
                <DataTemplate> 
                    <RadioButton IsChecked="{Binding CellBoundValue}"/> 
                </DataTemplate> 
        </syncfusion:GridDataVisibleColumn.CellItemTemplate> 
        <syncfusion:GridDataVisibleColumn.CellEditItemTemplate> 
                <DataTemplate> 
                   <RadioButton IsChecked="{Binding CellBoundValue}"/> 
                </DataTemplate> 
        </syncfusion:GridDataVisibleColumn.CellEditItemTemplate> 
 </syncfusion:GridDataVisibleColumn> 
 
 
UG Link: 
 
We have a SfDataGrid control like GridDataControl. But compare to GridDataControl, SfDataGrid having a better performance and flexibility. SfDataGrid assists you to create entirely customizable and highly interactive features used to display and manipulate the huge amount of data. So, we suggest you to use SfDataGrid instead of GridDataControl.

You can also refer the below documentation link to know more about SfDatagrid, 
 
Regards, 
Jai Ganesh S 



MK Maheshwar Komalla September 1, 2016 02:29 PM UTC

Thank you for the response. The question was if I have the two or more columns of RadioButton how would I make these columns mutual exclusive for each row?
I have attached the sample program where Columns A, B and C should be mutual exclusive for each row.
Appreciate your help!

Thanks
Mahesh

Attachment: RadioButtonPGSample_090116_e04b52ed.zip


JG Jai Ganesh S Syncfusion Team September 3, 2016 02:35 PM UTC

Hi Mahesh, 
 
Your requirement can be achieved by using GroupName property of RadioButton. We have prepared a sample for this requirement using SfDataGrid and the sample can be downloaded from the below location, 
                    
<syncfusion:GridTemplateColumn MappingName="A" syncfusion:FocusManagerHelper.WantsKeyInput="True"> 
                    <syncfusion:GridTemplateColumn.CellTemplate> 
                        <DataTemplate> 
                            <RadioButton syncfusion:FocusManagerHelper.FocusedElement="True"  IsChecked="{Binding A, UpdateSourceTrigger=PropertyChanged}"  
                                         GroupName="{Binding ID}" syncfusion:VisualContainer.WantsMouseInput="True" 
                                         Background="LightBlue" HorizontalAlignment="Center"/> 
                        </DataTemplate> 
                    </syncfusion:GridTemplateColumn.CellTemplate> 
</syncfusion:GridTemplateColumn> 
 
 
Regards, 
Jai Ganesh S 


Loader.
Live Chat Icon For mobile
Up arrow icon