Welcome to the Xceed Community | Help
Community Search  
More Search Options

Group header checkboxes

Sort Posts: Previous Next
  •  08-19-2010, 5:04 PM Post no. 28023

    Group header checkboxes

    Hi,

     

                   I’m working on functionality that allows a user to check or uncheck a group ina data grid using a checkbox in the group header. I’ve got that basicfunctionality—I added a checkbox to the group header via its content templateand recursively check the items in the group (and in any subgroups). But theproblem is that the group header checkbox is not synchronized in any way withthe checked states of the group’s items. Ideally, I’d like the group headercheckboxes to be tri-state checkboxes, which are checked if and only if all itschildren (including all its subgroups) are checked, unchecked if and only ifall its children are checked, and otherwise have a null checked value. Thisbehavior should be true all the way up the group hierarchy. Do you have anytips on how to do this? I’m currently trying to get the parent group control ofan item when an item’s (not a group’s) checkbox is checked. I can get theCollectionViewGroup object, but I have no idea how to access the group’s groupheader’s checkbox, nor how to walk up the chain to the top-level group.

  •  08-20-2010, 3:40 PM Post no. 28032 in reply to 28023

    Re: Group header checkboxes

    This question has been answered through email support:

    There is no easy and clean way to get it. Here is the only way the developer found:

       DataGridContext context = DataGridControl.GetDataGridContext( groupHeaderControl );

       // Get the GroupHeaderFooterItem of the actual GroupHeaderControl
       GroupHeaderFooterItem header = ( GroupHeaderFooterItem )context.GetItemFromContainer( groupHeaderControl );

       // Get the parent CollectionViewGroup from the current Group.ParentGroups' first item
       CollectionViewGroup parentCollectionViewGroup = context.GetParentGroupFromItem( groupHeaderControl.Group.ParentGroups[ 0 ].GetItems()[ 0 ] );

       // Create a GroupHeaderFooterItem from this CollectionViewGroup using the Template of the current GroupHeaderFooterItem's Template
       GroupHeaderFooterItem parentGroupHeaderFooterItem = new GroupHeaderFooterItem( parentCollectionViewGroup, header.Template );

       //Get the container for this item which will be an inner type inheriting ContentPresenter
       ContentPresenter groupHeaderFooterItem = context.GetContainerFromItem( parentGroupHeaderFooterItem ) as ContentPresenter;

       //Get the first Child of this ContentPresenter which will be the GroupHeaderControl of the parent level using VisualTreeHelper since it is created via a DataTemplate
       GroupHeaderControl parentGroupHeaderControl = VisualTreeHelper.GetChild( groupHeaderFooterItem, 0 ) as GroupHeaderControl;


    * We recommend that you add the many checks against null and index out of range that are missing from this code snippet, to avoid possible errors.

     


    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
  •  11-21-2010, 5:23 AM Post no. 29288 in reply to 28032

    Re: Group header checkboxes

    Hi,I would like to know if there is any change regard adding checkbox to each column and group header and keep the group header's checkbox in sync with the rows check box.

     

    Anyways, I would like to know how can I get hold of the header's checkbox if I have a row in the group.

     

    Thank you,

    Ido. 

  •  11-22-2010, 3:44 PM Post no. 29295 in reply to 29288

    Re: Group header checkboxes

    Hi Ido,

    To my knowledge there were no changes in regards to the behavior you are describing.

    If you are having an issue, please send your question and a small test project which reproduces the issue to support@xceed.com and we will be able to help you further. Thank you.

     


    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
  •  11-22-2010, 5:07 PM Post no. 29296 in reply to 29295

    Re: Group header checkboxes

    Hi Diane,

    thanks for let me know.

     Is there any way to get the direct group of a DataRow in the grid? And by the same token the group of the group if there is more then one level?

    Another way I thought about is some use the DataGridView grouping data model to somehow put my data inside of it and bind each group template to that data. Off course there are more question then answers but maybe it is a way.

     

    Thank you,

    Ido 

  •  11-23-2010, 1:54 AM Post no. 29297 in reply to 29296

    Re: Group header checkboxes

    Once you have the Xceed DataRow object and its DataGridContext, you can do the following (there maybe a shortcut but not aware of it):

    object dataItem = dataGridContext.GetItemFromContainer(container);

    if (dataItem != null)

    {

    CollectionViewGroup group = dataGridContext.GetParentGroupFromItem(dataItem);

    }

    You may find that this can also be used to get the ParentGroup of a Group item but I have not tried that.

  •  03-28-2011, 10:41 AM Post no. 30097 in reply to 28023

    Re: Group header checkboxes

    Hi,

    I have similar requirement as to add check box in data grid for selection. Basically when there is no grouping then show selection check box in first column of each row and column header. I have done this part. My next task is to add check for groups also. Group header and its corresponding rows should have check boxes for selection. Can you please share the example or guide lines as how to achieve this.

    Thanks for the help

    Amit

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.