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

how to group Radio Button in row in RadGridView?

2 Answers 82 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Arpit
Top achievements
Rank 1
Arpit asked on 08 Apr 2011, 11:59 AM
Hi,

    Scenario : I am having RadGridView, where I have to implement a table. This Table helps me in setting the UI setting of the application for the RadDocking. Here RadPanes can be pinned, unpinned, Hide and Open.
so, First column is having the Property names (pin, unpin, Hide) and other columns are having the panes names. One pane can have one property out of (pin,unpin and Hide). So, I defined the template for radiobutton column which is been grouped to select one radio button in the respective group.
For more information underneath I am attaching the xaml and .cs code for the same and the image for your reference -

XAML 
UserControl.Resources>
         
        <DataTemplate x:Key="RadioColumnTemplate1">
             
            <RadioButton x:Name="editBtn1" Height="20" Width="20" Checked="editBtn_Checked" GroupName="GroupNavigate" Tag="{Binding UPPane}"  />
        </DataTemplate>
        <DataTemplate x:Key="RadioColumnTemplate2">
            <RadioButton x:Name="editBtn2" Height="20" Width="20" Checked="editBtn_Checked"  GroupName="GroupAssignment" Tag="{Binding UPPane}" />
        </DataTemplate>
        <DataTemplate x:Key="RadioColumnTemplate3">
            <RadioButton x:Name="editBtn3" Height="20" Width="20" Checked="editBtn_Checked" GroupName="GroupMessageNotification"  Tag="{Binding UPPane}"/>
        </DataTemplate>
        <DataTemplate x:Key="RadioColumnTemplate4">
            <RadioButton x:Name="editBtn4" Height="20" Width="20" Checked="editBtn_Checked" GroupName="GroupStatusMessage" Tag="{Binding UPPane}" />
        </DataTemplate>
        <DataTemplate x:Key="RadioColumnTemplate5">
            <RadioButton x:Name="editbtn5" Height="20" Width="20" GroupName="GroupAll" Tag="{Binding UPPane}" />
        </DataTemplate>
        <!--<DataTemplate x:Key="RadRadioColumnTemplate">
            <telerik:RadRadioButton x:Name="editBtn"  Content="Radio Item" GroupName="one"  IsChecked="True"/>
        </DataTemplate>-->
         
    </UserControl.Resources>
     
    <Grid x:Name="LayoutRoot" Background="White">
        <telerik:RadGridView x:Name="MyGrid" AutoGenerateColumns="False"  ItemsSource="{Binding UPPaneNameCollection, Mode=TwoWay}" RowIndicatorVisibility="Collapsed">
        <telerik:RadGridView.Columns >
                <telerik:GridViewDataColumn Header="Pane Property" HeaderTextAlignment="Center" DataMemberBinding="{Binding UPPane}" IsFilterable="False"  Width="*"/>
                <telerik:GridViewColumn Header="Navigate" HeaderTextAlignment="Center"  CellTemplate="{StaticResource RadioColumnTemplate1}" Width="*"/>
                <telerik:GridViewColumn Header="Assignment" HeaderTextAlignment="Center" CellTemplate="{StaticResource RadioColumnTemplate2}" Width="*"/>
                <telerik:GridViewColumn Header="Message Notification"  HeaderTextAlignment="Center" CellTemplate="{StaticResource RadioColumnTemplate3}" Width="*"/>
                <telerik:GridViewColumn Header="Satus Message" HeaderTextAlignment="Center" CellTemplate="{StaticResource RadioColumnTemplate4}" Width="*"/>
                <!--<telerik:GridViewColumn Header="All" HeaderTextAlignment="Center" CellTemplate="{StaticResource RadioColumnTemplate5}" Width="*" />-->
                    
                 
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>

Code Behind -
public partial class UPPaneSettingView : UserControl
   {
       public UPPaneSettingView()
       {
           UPPaneSettingViewModel model = new UPPaneSettingViewModel();
           this.DataContext = model;
           InitializeComponent();
 
           // data binding
           RegionContext.GetObservableContext(this).PropertyChanged += (s, e) =>
                    model.tempProperty = RegionContext.GetObservableContext(this).Value as string;
       }
 
       private void editBtn_Checked(object sender, RoutedEventArgs e)
       {
 
           string _GroupName = ((System.Windows.Controls.RadioButton)sender).GroupName.ToString();
           string _PaneProperty = ((System.Windows.Controls.RadioButton)sender).Tag.ToString();
           IRegionManager regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
 
           // MainPageview is having the RadDocking and I am passing the RadPane names here
 
           EverestMainApplication.MainPageView mainPageView = (EverestMainApplication.MainPageView)EverestFunctions.GetView(ViewNames.MainPageView, regionManager.Regions[Regions.LoginScreenRegion]);
 
           switch (_GroupName)
           {
               case "GroupNavigate":
                   
                   switch (_PaneProperty)
                   {    
                            
                       case "UnPin":
                           mainPageView.PaneNavigationCommonModulRegion.IsPinned = false;
                           break;
                        
                       case "Pin":
                            
                           mainPageView.PaneNavigationCommonModulRegion.IsPinned = true;
                           break;                      
                    }
                   break;
               case "GroupAssignment":
                   switch (_PaneProperty)
                   {
                       case "UnPin":
                           mainPageView.PaneAssignmentRegion.IsPinned = false;
                           break;
                        
                       case "Pin":
                           if (mainPageView.PaneAssignmentRegion.IsHidden == true)
                           {
                               mainPageView.PaneAssignmentRegion.IsHidden = false;
                           }
                           mainPageView.PaneAssignmentRegion.IsPinned = true;   
                           break;
 
                       case "Hide":
                           mainPageView.PaneAssignmentRegion.IsHidden = true;
                           break;
 
                      
                   }
                   break;
                   
               case "GroupMessageNotification":
                  switch (_PaneProperty)
                   {
                       case "UnPin":
                           mainPageView.PaneMessageNotificationRegion.IsPinned = false;
                           break;
                        
                       case "Pin":
                           if (mainPageView.PaneAssignmentRegion.IsHidden == true)
                           {
                               mainPageView.PaneAssignmentRegion.IsHidden = false;
                           }
                           mainPageView.PaneMessageNotificationRegion.IsPinned = true;   
                           break;
 
                       case "Hide":
                           mainPageView.PaneMessageNotificationRegion.IsHidden = true;
                           break;
 
                        
                   }
                   break;
               case "GroupStatusMessage":
                  switch (_PaneProperty)
                   {
                       case "UnPin":
                           mainPageView.PaneStatusMessageRegion.IsPinned = false;
                           break;
                        
                       case "Pin":
                           if (mainPageView.PaneAssignmentRegion.IsHidden == true)
                           {
                               mainPageView.PaneAssignmentRegion.IsHidden = false;
                           }
                           mainPageView.PaneStatusMessageRegion.IsPinned = true;   
                           break;
 
                       case "Hide":
                           mainPageView.PaneStatusMessageRegion.IsHidden = true;
                           break;
                   }
                   break;
           };
       }
   }

Requirement :  I need to replace Property names to Panes names and implement the same logic. Means, first column woukd be of panes and other column would be having the properties (pin,unpin, hide). For your reference I am attaching the image  (UI-Setting2.png).

Problem: To implement the same, I need to group radiobuttons is column, can I do the same as I am not able to group the radiobuttons in row. Is there any way to implement the same.


2 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 08 Apr 2011, 12:57 PM
Hello Arpit,

 

I believe that the better approach here is to create your own custom column that directly inherits the GridViewDataColumn. Then you will be able to group this column.
You may take a look at the following forum thread and at the following blog post for further reference. 


Please let me know how this works for you!

Greetings,
Vanya Pavlova
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
Arpit
Top achievements
Rank 1
answered on 11 Apr 2011, 01:18 PM
Hi Vanya,
   Thanks for your reply. It was nice link of customizing column, however, here my need is to group the radiobuttons in row. Because, I need to choose any one property(pin,unpin,Hide) for a respective PaneName.
The one I have shown in UI-Setting2.png.

Regards,
Arpit
Tags
GridView
Asked by
Arpit
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Arpit
Top achievements
Rank 1
Share this question
or