How to change GridViewColumnGroup's Visibility ?

19 posts, 0 answers
  1. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 01 Dec 2011 Link to this post

    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.
  2. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 02 Dec 2011 Link to this post

    help please :(
  3. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 02 Dec 2011 Link to this post

    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 >>

  4. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 02 Dec 2011 Link to this post

    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.
  5. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 07 Dec 2011 Link to this post

    No reply :(
  6. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 07 Dec 2011 Link to this post

    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
  7. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 08 Dec 2011 Link to this post

    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 >>

  8. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 08 Dec 2011 Link to this post

    Thanks ;)
  9. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 14 Dec 2011 Link to this post

    Hi,

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

    Thanks.
  10. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 14 Dec 2011 Link to this post

    That's Ok, I know how to do ;)
  11. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 14 Dec 2011 Link to this post

    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.
  12. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 19 Dec 2011 Link to this post

    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 >>

  13. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 21 Dec 2011 Link to this post

    Ok, but how ?

    Can you send me a sample please.

    Thanks.
  14. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 21 Dec 2011 Link to this post

    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;
  15. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 22 Dec 2011 Link to this post

    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 >>

  16. Mike
    Mike avatar
    79 posts
    Member since:
    Nov 2011

    Posted 23 Dec 2011 Link to this post

    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.
  17. Chris
    Chris avatar
    26 posts
    Member since:
    Jul 2010

    Posted 23 Dec 2011 Link to this post

    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?
  18. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 26 Dec 2011 Link to this post

    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 >>

  19. Juliana
    Juliana avatar
    71 posts
    Member since:
    Feb 2008

    Posted 11 Feb 2013 Link to this post

    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
Back to Top