I have a set of columns and I want to group by multiple columns. For example, lets say i have the following columns:
Name|Age|School|Grade
I want to be able to group by Name and Age so I can see all the schools and grades for a particular name and age, or group by School and Grade and see all of the names and ages in that school/grade. (Note: I want this only to be a hierarchy/tree like, as in I dont want it to be grouped by school, then have a list of grades underneath which has a list of names/ages)
The only way I can determine to do this is to create another column for each grouping that concatenates the Name+Age or School+Grade and then group by that. Is there another way that I am missing?
The real problem though is, I want to be able to do this based on a radio button selection to pick the grouping type. How do you add groupby columns in code? I saw you can do this in the InitializeLayout event, as shown below, but how do you force the grid to initialize the layout again after the grid is already displayed, or is there another method of adding sorting columns that is easier?
private void gridName_InitializeLayout(object sender, InitializeLayoutEventArgs e){ e.Layout.Bands[0].SortedColumns.Add("ColumnKey", false, true);}
Thank you ahead of time for any help.
Hi I am currently doing something simila. Basically I need to group by multiple columns since one of them has multiple fields example:
column1 column2 column3
bla test 1
bla test 2
bla test 3
what i need is that it groups column1 and column2 so that it expands to show what there is in column3.
I tried to use to code suggested in this post but the grid stays in flat style and shows data as the example above, is there any other code i need to type in for this to work? Oh yeah I am currenty using version 7.1 don't know if it supports this functionality
Hi,
It's hard to say what you might be missing since you don't actually say what you are doing. :)
But there are basically two things you need to do to group column in code:
1) Set ViewStyleBand to OutlookGroupBy
2) Use the SortedColumns.Add method on the band and specify true for isGroupBy.
If you don't want the users to change the groupings, you will need to set GroupByBox.Hidden to true.