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

Hide gridviewdatacolumn when it is added in ColumnGroupDescriptor

6 Answers 265 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ankush
Top achievements
Rank 1
Ankush asked on 20 Oct 2012, 01:18 PM
Hi,
I am using a radgridview , in which i have few gridviewdatacolumn , i am adding a group descriptor for one of the column , and my requirement is, that column should be hidden from radgridview since i have grouped based on that, 
further GridViewColumn.ShowColumnWhenGrouped Property is not available to me as i am using an older version of telerik Dll, is their any other way to solve this problem?

 following is the xaml of code for more clarity, so i want column Element Path to be hidden as it is used in group descriptor -

 <telerik:RadGridView.Columns>
                                                <telerik:GridViewDataColumn  IsReadOnly="True"  IsGroupable="True"  Header="Element Path" DataMemberBinding="{Binding ElementPath}" Focusable="False" Width="Auto" TextAlignment="Left" IsEnabled="False"/>
                                                <telerik:GridViewDataColumn  IsReadOnly="True"  IsGroupable="True"  Header="Category" DataMemberBinding="{Binding CategoryName}" Focusable="False" Width="Auto" TextAlignment="Left" IsEnabled="False" />
                                                <telerik:GridViewDataColumn IsReadOnly="True"  IsGroupable="False"  Header="Name" DataMemberBinding="{Binding Name}" Width="Auto" Focusable="False" TextAlignment="Left" IsEnabled="False" />
                                                <telerik:GridViewDataColumn IsReadOnly="True"  IsGroupable="False"  Header="Description" HeaderTextAlignment="Left" DataMemberBinding="{Binding Description}" Focusable="False" Width="200" TextAlignment="Left" IsEnabled="False" />
                                                <telerik:GridViewDataColumn IsReadOnly="True"  IsGroupable="True"  Header="Type" DataMemberBinding="{Binding CannonicalType}" Focusable="False" TextAlignment="Left" Width="Auto" IsEnabled="False" />
                                                <telerik:GridViewDataColumn  Header="Value"  IsGroupable="False"  Width="180"  DataMemberBinding="{Binding Value,Mode=TwoWay,ValidatesOnExceptions=True}"  CellTemplateSelector="{StaticResource CellTemplate}" CellEditTemplateSelector="{StaticResource EditTemplateSelector}"  SortingState="None" IsSortable="True"  TextAlignment="Left" IsEnabled="True">
                                                    <telerik:GridViewDataColumn.CellStyle>
                                                        <Style  BasedOn="{StaticResource {x:Type tt:GridViewCell}}" TargetType="tt:GridViewCell">
                                                            <Setter Property="FontWeight" Value="Normal" />
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding Path=IsDefaultValueModified,Mode= TwoWay}" Value="true">
                                                                    <Setter Property="FontWeight" Value="Bold" />
                                                                </DataTrigger>
                                                                <DataTrigger Binding="{Binding Path=ParameterInEditMode, Mode=TwoWay}"  Value="true">
                                                                    <Setter Property="FontStyle" Value="Italic" />
                                                                </DataTrigger>
                                                                <DataTrigger Binding="{Binding IsEnabled}" Value="true">
                                                                    <Setter Property="IsEnabled" Value="true" />
                                                                    <Setter Property="Focusable" Value="true" />
                                                                </DataTrigger>
                                                                <DataTrigger Binding="{Binding IsEnabled}" Value="false">
                                                                    <Setter Property="IsEnabled" Value="false" />
                                                                    <Setter Property="Focusable" Value="false" />
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </telerik:GridViewDataColumn.CellStyle>
 
                                                </telerik:GridViewDataColumn>
                                                <telerik:GridViewDataColumn  IsGroupable="False" IsReadOnly="True" Header="Resolved Value" DataMemberBinding="{Binding ResolvedValue}" TextAlignment="Left" Width="180" IsEnabled="False"/>
 
                                            </telerik:RadGridView.Columns>
                                            <telerik:RadGridView.GroupDescriptors>
                                                <telerik:ColumnGroupDescriptor>
                                                    <telerik:ColumnGroupDescriptor.Column>
                                                        <telerik:GridViewColumn Header="Element Path"  GroupMemberPath="ElementPath" />
                                                    </telerik:ColumnGroupDescriptor.Column>
                                                </telerik:ColumnGroupDescriptor>
                                            </telerik:RadGridView.GroupDescriptors>




6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 23 Oct 2012, 08:49 AM
Hello,

You can set the grouped column be not visible once a Grouping event with GroupingEventAction.Place is raised. For example:

private void clubsGrid_Grouping(object sender, GridViewGroupingEventArgs e)
      {
          if (e.Action == GroupingEventAction.Place)
          (e.GroupDescriptor as ColumnGroupDescriptor).Column.IsVisible = false;
      }

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ankush
Top achievements
Rank 1
answered on 23 Oct 2012, 01:49 PM
Hi,

Using grouping event i can hide the visibility,  once i add( drag and drop the GridViewcolumn header ) or remove it from group panel , but since column group descriptor shows gridviewcolumn to be grouped as the window opens , i need a solution which hides the visibility of gridviewcolumn as the window opens. Is their any solution available for that.


Thanks ,
Ankush.
0
Dimitrina
Telerik team
answered on 24 Oct 2012, 01:16 PM
Hello,

 You could check the RadGridView.GroupDescriptors that are initially defined and based on the information from them hide the proper columns.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ankush
Top achievements
Rank 1
answered on 24 Oct 2012, 03:42 PM
hi,
Which event of radgrpoupDescriptor should i use so that i can get my desired result , if i am using Loaded event of radgridview and writing the following code in it , it is not hiding the corresponding column when window opens-

 private void rad1_Loaded(object sender, RoutedEventArgs e)
        {
            ColumnGroupDescriptor gd = rad1.GroupDescriptors[0] as ColumnGroupDescriptor;
            //ColumnGroupDescriptor gd1 = gd;
            gd.Column.IsVisible = false;
        }
  
Thanks,
Ankush.
0
Dimitrina
Telerik team
answered on 25 Oct 2012, 11:09 AM
Hi Ankush,

I have tested this code and it works fine at my end. Please find attached my test project.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ankush
Top achievements
Rank 1
answered on 25 Oct 2012, 02:45 PM
hi didie,

I am not sure why using the similar code , this approach is not working for me ,
well any how i have fixed this by using following code-

    
 private void rad1_Loaded(object sender, RoutedEventArgs e)
        {
            //ColumnGroupDescriptor gd = rad1.GroupDescriptors[0] as ColumnGroupDescriptor;
            ////ColumnGroupDescriptor gd1 = gd;
            //gd.Column.IsVisible = false;
         ////   if (!isDefaultGroupingLoaded)
            {
                //   isDefaultGroupingLoaded = true;
                ColumnGroupDescriptor des = new ColumnGroupDescriptor();
                des.Column = rad1.Columns["FirstName"as Telerik.Windows.Controls.GridViewColumn;
                des.DisplayContent = "FirstName";
                des.SortDirection = null;
                rad1.GroupDescriptors.Add(des);
                des.Column.IsVisible = false;
            }
        }

thanks for your help.
Tags
General Discussions
Asked by
Ankush
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Ankush
Top achievements
Rank 1
Share this question
or