Hey,
I am using UltraWinGrid and would like to use column grouping as shown in the attached image. The features that I must have are:
I also need to use a creation filter to get HeaderUIElement objects from its parent BandHeadersUIElement. I may need to replace HeaderUIElement objects by my own HeaderUIElement (derived classes from HeaderUIElement).
Your help is greatly appreciated!
Best Regards,Shaolin
Hello Shaolin,
In order to group the grid's columns the way you want, first you have to create the groups “Group 1”, etc. and add them to the band’s GroupsCollection. Then, you set the band's RowLayoutStyle to GroupLayout and the group column as parent to the subcolumns: "Grp1 Col1" and "Grp1 Col2"
UltraGridBand band = e.Layout.Bands[0]; band.RowLayoutStyle = RowLayoutStyle.GroupLayout; UltraGridGroup firstGroup = band.Groups.Add("FirstGroup", "Group1"); band.Columns["Grp1 Col1"].RowLayoutColumnInfo.ParentGroup = firstGroup;band.Columns["Grp1 Col2"].RowLayoutColumnInfo.ParentGroup = firstGroup;
UltraGridBand band = e.Layout.Bands[0];
band.RowLayoutStyle = RowLayoutStyle.GroupLayout;
UltraGridGroup firstGroup = band.Groups.Add("FirstGroup", "Group1");
band.Columns["Grp1 Col1"].RowLayoutColumnInfo.ParentGroup = firstGroup;band.Columns["Grp1 Col2"].RowLayoutColumnInfo.ParentGroup = firstGroup;
As by default the grid will place grouped columns before non-grouped columns, you have to arrange the columns and groups in the order you want by using the OriginX property on the RowLayoutColumnInfo or RowLayoutGroupInfo.
To make "Column 1", “Column 2”, etc. span vertically, you would need to set their SpanY property to 2 (one for the group header and one for the column headers within the groups).
The following forum thread regarding grouped column arrangement might help https://ko.infragistics.com/community/forums/t/60282.aspx
You can enable all of the listed functionalities either in the grid’s designer by clicking the Start button and selecting the Feature Picker from the left-pane tab or in code.
Sorting is under the ‘Header Sort Click Action’ and you can allow the user to sort on both single and multiple columns by clicking on the column headers. In code, you have to set the HeaderClickAction property:
e.Layout.Override.HeaderClickAction = HeaderClickAction.SortSingle;
You can enable filtering by expanding the ‘Filtering’ node and then selecting the Allow option or in code:
e.Layout.Override.AllowRowFiltering = DefaultableBoolean.True;
You can enable fixed columns either in designer under the ‘Fixed Headers’ node or by setting the Fixed property on column headers and/or group headers. You can find a sample on the fixed header functionality on the following link:http://help.infragistics.com/Help/Doc/WinForms/2011.2/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v11.2~Infragistics.Win.UltraWinGrid.HeaderBase~Fixed.html
The grid has built-in functionality for allowing the user to move and swap columns. By default, column moving is enabled in non-Row Layout mode. In Row Layout mode you must explicitly enable column moving by setting the AllowColMoving to WithinBand.
Column swapping is not enabled by default. To enable it, you must set the AllowColSwapping to WithinBand.
Column groups can be moved and swapped in exactly the same manner as columns. You must set the AllowGroupMoving and AllowGroupSwapping properties as appropriate.
You can find more information on the UltraGrid on https://ko.infragistics.com/help/winforms/wingrid. The ‘Using WinGrid’ section provides information and examples on all the main built-in grid’s functionalities.
You can find more information about Creation Filter on https://ko.infragistics.com/help/winforms/win-creation-filter. I also recommend using the Infragistics UIElementViewer Utility in this case because it will allow you to move your mouse over the grid and see its UIElements.
Please let me know if you need further assistance regarding this matter.
Hi Plamena,
Thanks so much for your quick reply!
One of the requirements I mentioned is Fixed columns and groups, which is not supported with the group layout. The RowLayoutStyle is set to None. Can you send me a sample application please?
Indeed the fixed headers functionality is not supported in GroupLayout mode because these two features are mutually exclusive. The only functionality that is closer to fixed columns is using a ColScrollRegion, which is very similar to the splitter bars in Excel. The user can split the screen horizontally by dragging the Column Split Box to the Right.
The alternative would be to turn off RowLayouts and use Groups in the normal mode. You could add ungrouped columns into a group all by themselves. I have attached a sample project that does not use the GroupLayout. Each column has a group, "Grp1 Col1" and "Grp1 Col2" both belong to the MergedColumn.
I am working on it and I will solve this issue myself.
Thanks,Shaolin
Hi Shaolin,
Do you have any other questions I can help you with?
Thanks so much for your reply!
Merging Group and Column headers might be possible using Creation Filter but I do not recommend this approach because its implementation is going to be extremely tricky and complicated. The grid has many functionalities that have to be taken into consideration and might end up not working.
ColScrollRegion defines a region that scrolls columns. When the grid is not splitted, it has one ColScrollRegion. The splitting functionality divides the grid into two or more ColScrollRegions.
Having fixed columns only without the groups is quite controversial and the current grid design does not support it. If there are groups, then the Fixed property settings of the group headers will be used and fixed property settings of the column headers will be ignored.
Thanks so much for your Sample app.
Is there a way to combine column header with its empty group header for those individual columns (Column 1, 2 ...) that are not in any group?
Why is this approach called something related to ColScrollRegion? I knew this approach a while ago but did not know it has any thing to do with ColScrollRegion. Sorry, it is just my curiosity :-)