System Groups vs User Defined Groups

2 posts, 1 answers
  1. Tony
    Tony avatar
    21 posts
    Member since:
    Oct 2011

    Posted 23 Jan 2012 Link to this post


    I'm wondering if it is possible to achieve the following requirement with a gridview.

    Assume that we have a grid where each row has the following columns:
    * ID
    * City
    * Department
    * Name
    * Sex

    I want to be able to specify system groups that the user cannot alter yet at the same time allow users to specify user defined groups.

    For example, I want to force the 1st level grouping on City.  I don't want users to be able to remove this grouping (they should still be able to change the sorting on it though).  However, they can choose to add additional groups (e.g. 2nd level grouping on Department) so the grid will look something like
    City 1
        |---> Department 1
                    |---> Person 1
                    |---> Person 2
        |---> Department 2
                    |---> Person 3
    City 2

    Is this possible?

    Thanking you in advance for your assistance.

  2. Answer
    Pavel Pavlov
    Pavel Pavlov avatar
    2039 posts

    Posted 23 Jan 2012 Link to this post

    Hi Tony,

    You can programmatically add your group initially adding a group descriptor. Later when the user tries to ungroup , you may prevent this by handling the Grouping  event such as :
    void clubsGrid_Grouping(object sender, GridViewGroupingEventArgs e)
            if (e.Action == GroupingEventAction.Remove)
                e.Cancel = true;

    *You will need to add a check for e.GroupDescriptor in order to cancel the ungroup action only for the relevant group descriptor and leave the user ungroup by the rest.

    In case you meet troubles implementing do not hesitate to contact me.

    Pavel Pavlov
    the Telerik team

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

Back to Top