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

How to change GridViewColumnGroup's Visibility ?

18 Answers 395 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 01 Dec 2011, 04:37 PM
Hi,

I'm looking for the way to access a GridViewColumnGroup from code behind. I want to change dynamically the visibility of some Column group like that : Gp1.Visibility = Visibility.Collapsed;
<telerik:RadGridView.ColumnGroups>
                                    <telerik:GridViewColumnGroup Header="Gp1" Name="Gp1"/>
                                    <telerik:GridViewColumnGroup Header="Gp2" Name="Gp2"/>
                                    <telerik:GridViewColumnGroup Header="Gp3" Name="Gp3"/>
                                </telerik:RadGridView.ColumnGroups>

I've tested the following code, but it doesn't work :

MyGrid.Columns.["Gp1"].IsVisible = false;

So, when I hide all group childs, the group visibility change (that's ok). but it stays collapsed even if I change the visibility of Childs to Visible.

Is that is normal ? how can I hide/display a column Group and all of its childs ?

Thanks.

18 Answers, 1 is accepted

Sort by
0
Mike
Top achievements
Rank 1
answered on 02 Dec 2011, 04:40 PM
help please :(
0
Pavel Pavlov
Telerik team
answered on 02 Dec 2011, 04:46 PM
Hi Radouan,

When you set the visibility to false .. a an empty placeholder would remain .. which is kind of visually inconsistent. What exactly is the final goal you are trying to achieve ?

All the best,
Pavel Pavlov
the Telerik team

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

0
Mike
Top achievements
Rank 1
answered on 02 Dec 2011, 04:57 PM
Hello Pavel,

What  I'm looking for is :

1/ hide the ColumnGroup when all of its childs are hidden

2/ show the ColumnGroup when at least one of its childs is visible.

How can I do That ?

Thanks.
0
Mike
Top achievements
Rank 1
answered on 07 Dec 2011, 10:51 AM
No reply :(
0
Mike
Top achievements
Rank 1
answered on 07 Dec 2011, 11:27 AM
for exemple, how can I change the visibility of column "Dimensions" ?

<telerik:RadGridView.ColumnGroups>
    <telerik:GridViewColumnGroup  Name="Data" Header="Data">
        <telerik:GridViewColumnGroup  Name="VehicleInfo" Header="Vehicle info" />
        <telerik:GridViewColumnGroup  Name="Dimensions" Header="Dimensions" />
    </telerik:GridViewColumnGroup>
</telerik:RadGridView.ColumnGroups>


http://www.telerik.com/help/silverlight/media/RadGridView_ColumnHeaders_8.png
0
Pavel Pavlov
Telerik team
answered on 08 Dec 2011, 02:00 PM
Hello Radouan,

Please excuse me for the delayed answer. We were trying to find a descent workaround . Since currently changing the visibility runtime is not supported we have decided to implement an improvement to the merged column headers logic allowing this behavior .

It will be present in the very next internal build ( Monday)  and officially in the very next service pack ( within two weeks) .

Regards,
Pavel Pavlov
the Telerik team

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

0
Mike
Top achievements
Rank 1
answered on 08 Dec 2011, 02:03 PM
Thanks ;)
0
Mike
Top achievements
Rank 1
answered on 14 Dec 2011, 04:04 PM
Hi,

Can you tell me how can I download the new SP if available ?

Thanks.
0
Mike
Top achievements
Rank 1
answered on 14 Dec 2011, 05:09 PM
That's Ok, I know how to do ;)
0
Mike
Top achievements
Rank 1
answered on 14 Dec 2011, 05:47 PM
I'im using the new version of dlls and can't find the way to hide GridViewColumnGroup.

Is this available in the current build ?

Thanks for reply.
0
Pavel Pavlov
Telerik team
answered on 19 Dec 2011, 03:05 PM
Hello Radouan,

Yes with the latest internal build you can add or remove column groups to the RadGridView.ColumnGroups collection on the fly. The UI will be updated and newly added will appear. Respectively removed groups will disappear.

Best wishes,
Pavel Pavlov
the Telerik team

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

0
Mike
Top achievements
Rank 1
answered on 21 Dec 2011, 10:32 AM
Ok, but how ?

Can you send me a sample please.

Thanks.
0
Mike
Top achievements
Rank 1
answered on 21 Dec 2011, 10:43 AM
using the latest internal build, I can't find the property IsVisible.

What I'm looking for is to do like the following code :

PartsPotentialUI.ColumnGroups[0].IsVisible = true;
PartsPotentialUI.ColumnGroups[0].IsVisible = false;
0
Pavel Pavlov
Telerik team
answered on 22 Dec 2011, 01:41 PM
Hello Radouan,
I am attaching a small sample demonstrating what I meant.

Kind regards,
Pavel Pavlov
the Telerik team

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

0
Mike
Top achievements
Rank 1
answered on 23 Dec 2011, 10:49 AM
Hello Pavel,

Thanks for the sample, but I don't get what I'm looking for :(

1 - How can I hide all groupes ? I used RadGridView1.ColumnGroups.Clear(); but doesn't work, it fires an exception

2 - Removing a group doesn't remove childrens. This is an example of what kind of behavior I want :

--------------------------------------------
Group1
--------------------------------------------
Col1     |        Col2      |      Col3

if I set Group1's visibility to false => all childs must also change the visibility. Exactly like the silverlight Grid. If you set a Grid visiblity to Visibility.Collapsed, all children becomes collapsed.

Thanks.
0
Chris
Top achievements
Rank 1
answered on 23 Dec 2011, 08:24 PM
I have to agree, there should be a boolean property called .IsVisible to show/hide the column group header??!!!
WHen will this be in place?
0
Pavel Pavlov
Telerik team
answered on 26 Dec 2011, 02:58 PM
Hello Radouan ,

You are right . Indeed there was a problem with an out of range exception which is now fixed. The LIB tomorrow will contain the fix . Clearing the collection should now behave properly.

Kind regards,
Pavel Pavlov
the Telerik team

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

0
Juliana
Top achievements
Rank 1
answered on 11 Feb 2013, 01:13 PM
Hi Pavel,

I use Telerik controls v. 2012.3.1217.1050 an still get ArgumentOutOfRangeException when I try to change column IsVisible property. The call stack is

{System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at Telerik.Windows.Controls.GridView.CommonHeaderPresenter.GetGroupNameByIndex(List`1 subHeaders, Int32 index)
   at Telerik.Windows.Controls.GridView.CommonHeaderPresenter.RealizeHeadersAtRow(Int32 row, List`1 subHeaders)
   at Telerik.Windows.Controls.GridView.CommonHeaderPresenter.RealizeHeaders()
   at Telerik.Windows.Controls.GridView.CommonHeaderPresenter.PlaceCommonHeaders()
   at Telerik.Windows.Controls.GridView.CommonHeaderPresenter.RefreshCommonHeaders()
   at Telerik.Windows.Controls.GridView.CommonHeaderPresenter.NotifyCellsPropertyChanged(String propertyName, DependencyPropertyChangedEventArgs e)
   at Telerik.Windows.Controls.GridView.GridViewHeaderRow.NotifyPropertyChanged(DependencyObject d, String propertyName, DependencyPropertyChangedEventArgs e, UpdateTarget target)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.NotifyPropertyChanged(DependencyObject d, String propertyName, DependencyPropertyChangedEventArgs e, UpdateTarget target)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.NotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e, UpdateTarget target)
   at Telerik.Windows.Controls.GridViewColumn.NotifyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e, UpdateTarget target)
   at Telerik.Windows.Controls.GridViewColumn.IsVisibleChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
   at Telerik.Windows.PropertyMetadata.PropertyChangeHook.OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isBindingInStyleSetter)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Telerik.Windows.Controls.GridViewColumn.set_IsVisible(Boolean value)
  
What am I doing wrong? Please, provide any help on how I can hide/show columns within column group.

Thanks,
Juliana
Tags
GridView
Asked by
Mike
Top achievements
Rank 1
Answers by
Mike
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Chris
Top achievements
Rank 1
Juliana
Top achievements
Rank 1
Share this question
or