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)?
Andrej Kuklin said:Can I for instance "collapse" the whole group, so that the columns in the group are not visible?
No, there's no built-in way to collapse a group. You could set the group width to 0, I guess.
Andrej Kuklin said:Or move the groups around like columns (changing the order of columns in the grid)?
Yes, by setting AllowGroupMoving, just like AllowColMoving.
Andrej Kuklin said: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 not really sure about this. I don't think a group has any autosizing functioanlity, though.
Mike
I want to make the column 3 and 4 look like this:
Hi,
The best way to do this would be to use the RowLayoutStyle property and set it to GroupLayout. Column1 and Column2 would belong to Group1. Column3 and Column4 do not belong to any group and they span the height of the entire group.
Mike Add to my property RowLayoutStyle code and the results are not expected (see file), please help me with a code sample, I detail the code used.
grid.DisplayLayout.Bands[0].RowLayoutStyle = RowLayoutStyle.GroupLayout;grid.DisplayLayout.Bands[0].Columns["Column1"].Header.Caption = "Column1";grid.DisplayLayout.Bands[0].Columns["Column2"].Header.Caption = "Column2";grid.DisplayLayout.Bands[0].Groups.Add("Group1", "Group1");grid.DisplayLayout.Bands[0].Groups["Group1"].Columns.Add(grid.DisplayLayout.Bands[0].Columns["Column1"]);grid.DisplayLayout.Bands[0].Groups["Group1"].Columns.Add(grid.DisplayLayout.Bands[0].Columns["Column2"]);grid.DisplayLayout.Bands[0].Columns["Column3"].Header.Caption = "Column3";grid.DisplayLayout.Bands[0].Columns["Column4"].Header.Caption = "Column4";
Greetings
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.
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; }