I can only see that this is possible in a WebGrid. Can anyone help to determine whether this is possible in a grid with a single band of data?
To elaborate, three of the column headers will be different geographical regions, and so I would like a header that spans above all the individual column headers that says "Regions".
I've been searching the forums and knowledge base but I can't see any clues - any help is much appreciated!
Thanks.
There are two ways to do this.
1) Use Groups. You can add a Group to the band for each region and then assign each column to a group.
2) Use RowLayouts. This is more complex and you would need to add some unbound columns to the grid to represent the regions, then set the LabelPosition on these columns to LabelOnly and position them using the grid designer.
Mike, can these groups actually react to something? Or are they only be used as "extra-headers for a collection of groups"? Can I for instance "collapse" the whole group, so that the columns in the group are not visible? Or move the groups around like columns (changing the order of columns in the grid)? Can I configure the auto-size behavior (double-click on the border of the group header -> all columns in the group will be autosized)?
I'm on other part of the project i'll be back with this problem soon.
But i think what i've read help me.
Hello Steve,
I wanted to know if you were able to solve your issue based on these suggestions or you still need help. Please let me know.
Hi Steve,
The group header doesn't have any support for displaying a sort indicator. But you could sort on a column and have that column consider both columns by using a SortComparer on one or both of the columns.
Hi,
i try to use groups to span title for two colomn.
but is it possible to sort on groups?
Thanks!
Steve
This is a lot easier to do at design-time in the grid designer than in code. Using RowLayouts in code requires a lot of knowledge about how GridBagLayouts work.So if you can, I recommend binding the grid to the data source at design-time.
If your data structure does not exist at design-time, then you can still use the grid designer to establish the data schema manually. Just make sure that the band and column names all match up to the real data source you will be binding to at run-time and that you bind the grid using the SetDataBinding method.
The layout you have here is a pretty simple one, so you could do it in code if you really want to, but the designer would be a lot easier - it allows you to simply arrange things via drag and drop and using context menus.
The main problem with the code you have here is that the Group.Columns collection is only used for the Groups & Levels layout (Standard layout), not for a GroupLayout. So that's why your columns are not within the group.
Here's some quick sample code I threw together which seems to do what you want:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; band.RowLayoutStyle = RowLayoutStyle.GroupLayout; UltraGridGroup group1; if (band.Groups.Exists("Group 1")) group1 = band.Groups["Group 1"]; else group1 = band.Groups.Add("Group 1"); band.Columns["Column 1"].RowLayoutColumnInfo.ParentGroup = group1; band.Columns["Column 2"].RowLayoutColumnInfo.ParentGroup = group1; // If you want the height of the column headers outside the group to // fill the entire height, you would add this code: //band.Columns["Column 3"].RowLayoutColumnInfo.SpanY = 4; //band.Columns["Column 4"].RowLayoutColumnInfo.SpanY = 4; //band.Columns["Column 3"].RowLayoutColumnInfo.LabelSpan = 4; //band.Columns["Column 4"].RowLayoutColumnInfo.LabelSpan = 4; }