Hi,
e.Layout.Bands[0].SortedColumns.Add("Date", false, true);
Group by column is done using above code but my problem is I dont want sorting on Date Column. Following is the example of Data in data table and its display in grid with sorting of Date column That i don't want.
Is there any other way to Group Column in code?
The grid must sort the data before it can be grouped, becasue the rows with similar values must be next to each other.
Hi Mike, If i want to Rearrange row after sort then in which event should i write code? and and which property i have to set for change the row index?
Let's say I'm binding a list of objects to the UltraGrid, and I want to group the rows by one of the properties of the object. How do I set this up?
I see that I can make the UltraGrid sort by the property in question, but what about the GroupHeader and the UltraGridGroupByRows?
Thanks,
Chris McKenzie
Hi Chris,
I don't understand your question. The very first post in this thread gives you the line of code you would use in order to group a column programmatically. You call the SortedColumns.Add method and pass in true for the groupBy parameter.
Okay, let's set some preliminary context. I have a list of objects which among other properties has a "Level" property. "Level" here is some arbitrary integer value.
Now I have the following two lines of code:
Me.Control.Bands(0).SortedColumns.Add("Level1", False, True) Me.Control.Bands(0).GroupHeadersVisible = True
Let's say I have 3 objects where "Level1"=1, and 3 where "Level1" = 2.
From the documentation ( http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v8.2~Infragistics.Win.UltraWinGrid.UltraGridGroupByRow.html ) I would expect to see a an UltraGridGroupByRow which is expandable to view three rows that contain a Level1 property = 1, and a second UltraGridGroupByRow expandable to view three rows where Level1=2.
What I'm seeing instead is no row representing any kind of grouping. Rather, the rows are sorted by the Level1 property as expected, but other than the sort, there is no visible grouping of any kind in the control.
I've tried experimenting with the UltraGridGroup class as well. Adding an UltraGridGroup class does create a Group Header, but it doesn't actually contain any rows. All rows are still in the bottom of the grid.
I've been unable to find any documentation or samples that show how this is supposed to actually work.
Groups and OutlookGroupBy are two different things and you seem to be mixing them up - which is understandable since that have such similar names. But you have to be careful about that. GroupHeadersVisible deals with Groups, which are column groupings - it has nothing to do with OutlookGroupBy.
Anyway, my guess is that your OutlookGroupBy isn't working because you need to set the grid.DisplayLayoutViewStyleBand on the grid to OutlookGroupBy.
Okay, this is clearing some things up somewhat. Thank you.
Next problem: I am binding a list of objects of type A to the grid. Each object A has a property B which is another type of object. In the column that edits B, I have a dropdown containing the list of valid B objects that can be assigned to A. When I group by B, I get multiple groups for the same value of B (b1, b1, b1, b2, b2, b2, b3, b3, b3) instead of 1 group for each value of B (b1, b2, b3). Can you point me in the right direction for dealing with this?
Also, is there any way to get an add-row on the grid while it is in group-by mode? Finally, so I don't have to keep bothering you every time I hit the next stumbling block, do you have any extensive sample applications of the Ultragrid using rich complex objects as a data source?
The way OutlookGroupBy works is that the grid column is first sorted by the value, and then the group loops over the rows looking for values that match up. So if your cell values are custom objects, then when the grid tries to check if one is equal to another, it will do a reference comparison and they will never be equal. If you want different objects with the same value to be considered equal to each other, you will either need to override the Equals method on the object or implmenet your own ICustomGroupByEvaluator for the grid column.