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

System Groups vs User Defined Groups

1 Answer 30 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 23 Jan 2012, 01:12 PM
Hi,

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.

Tony

1 Answer, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 23 Jan 2012, 01:25 PM
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.

Regards,
Pavel Pavlov
the Telerik team

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

Tags
GridView
Asked by
Tony
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or