Select/unselect all options on group header

6 posts, 2 answers
  1. Joan
    Joan avatar
    9 posts
    Member since:
    Feb 2011

    Posted 07 Jun 2011 Link to this post

    Hi all,

    I must add a select all checkbox and an unselect all button to a RadGridView groups. The grouping is done by the user, the default view is a normal grid without groups, but the grouping option is enabled so the user can group the rows. The SelectionMode is set to Extended.
    When the user has done so I must add a checkbox and a button to the header. First I suppose I'll have to edit the GroupHeaderTemplate or the GroupRowStyle (I still don't know which one) to add the checkbox and the button, that's not a problem. What I don't know how to do is selecting/unselecting only the rows that are part of that particular group.
    Besides, when the user manually selects or unselects the checkbox IsChecked property must be refreshed.
    How would I achieve that? I'm using MVVM, my ViewModel IsSelected property is already binded to the GridViewRow IsSelected property in TwoWay mode, that part works.

    Thanks in advance,
    -Tony
  2. Joan
    Joan avatar
    9 posts
    Member since:
    Feb 2011

    Posted 08 Jun 2011 Link to this post

    I've half-solved my problem.

    Instead of having a checkbox it's just a button to select all. This means I don't need to keep track of the "all items selected" status. I've had to modify the GridViewGroupRowTemplate and use a Behavior.
    This method works so far but it's just a temporary workaround, I'll need a checkbox in the future so I still need to know how I can know whether all items in a group are selected and be refreshed of this value.

    Regards,
    -Tony
  3. Answer
    Milan
    Admin
    Milan avatar
    1989 posts

    Posted 09 Jun 2011 Link to this post

    Hello Tony,

    Please take a look at this sample implementation.

    Hope it helps.


    Greetings,
    Milan
    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
  4. Joan
    Joan avatar
    9 posts
    Member since:
    Feb 2011

    Posted 20 Jun 2011 Link to this post

    Hello Milan,

    First, sorry about the late reply, I've been very busy with something else.

    Your sample solves some issues, but there are still some problems. I wanted to check what happens with more than one item per group (but still more than one group), so I modified one method this way:

    public static IList<Customer2> GetAll()
    {
        return (from index in Enumerable.Range(1, 20)
                select new Customer2
                {
                    ID = index,
                    Age = 20,
                    Name = "Customer " + (index % 4 + 1),
                    JobCode = 1000 + index,
                    City = "Halifax"
     
                }).ToList();
    }

    Note the "Name" line. This way I have 5 items per group when grouping by Name. Every time I use the checkbox on the Group header everything works well, the problem comes when I individually select or unselect an item, the group's checkbox isn't refreshed. The result is the attached image.

    Basically, I need a way to receive a message every time an item selection changes from every group. Easier said than done. Maybe a mix of events and attached properties? I don't mind inheriting RadGridView if I must, in fact, I've already done so.

    Thanks,
    Tony

    EDIT: I attached a different image than intended and I can't remove an attachment. The correct file is "GroupRefreshProblem.png".
  5. Answer
    Milan
    Admin
    Milan avatar
    1989 posts

    Posted 23 Jun 2011 Link to this post

    Hi Tony,

    That ca be fixed by simply calling InitializeCheckState in the 
    GridView_SelectionChanged event handler in GroupSelectionBehavior




    Best wishes,
    Milan
    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
  6. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 22 Mar 2012 Link to this post

    Hi,

    I found another refresh problem :(

    check all group checkboxes, expand a group to make the last group dissapear over the bottom display area, unexpand all groups and now some group checkboxes becomed unchecked!!!

    Thank's
Back to Top