How can I reset row grouping programmatically ? The following statement does nothing:
if (ultraGrid1.Rows.IsGroupByRows) ultraGrid1.DisplayLayout.ResetGroupByBox();
ultraGrid1.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;
ultraGrid1.DisplayLayout.Override.AllowGroupBy = DefaultableBoolean.True;
Thank for a hint
Kagel
Got doing something else...
Looked at it this morning and 'sussed it', as Zaphod would say.
This clears all Grouped columns and leaves my previous Sorts in place.
Private Sub tsmiViewUnpivot_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsmiViewUnpivot.Click 'un pivot the grid For Each band As Infragistics.Win.UltraWinGrid.UltraGridBand In uwgRequirements.DisplayLayout.Bands Dim i As Integer = band.SortedColumns.Count - 1 While i >= 0 Dim col As Infragistics.Win.UltraWinGrid.UltraGridColumn = band.SortedColumns(i) If col.IsGroupByColumn = True Then band.SortedColumns.Remove(band.SortedColumns(i).Key) End If i = i - 1 End While Next AdjustCheckedMenuItems() End Sub
Mmmm, not so much ambiguous as opening more options.
In the case you describe I would ask the customer what they felt they wanted it to do (keep their last sort of the column or back sorts made while grouped out)...
But I see what you are saying.
Thanks, Mike.
Mitchster
Hi MItchster,
Okay, I didn't realize you were trying to make a distinction between sorting via clicking on the column header and sorting by grouping. When you group a column, it is sorted first and the grid has no reason to keep track of why it was sorted, only that it is.
So you are correct that if you want to separate the two operations, you would have to jump through some hoops. You could probably use the BeforeSortChange event to detect the individual changes to the SortIndicator, the IsGroupByColumn or both.
But what you are describing seems a little ambiguous to me. For example, suppose a user sorts a column. Then he groups a column (which sorts that column ascending). Then he clicks on the GroupBy header to sort that column descending?
Would you maintain the descending sort on that grouped column when you ungroup or discard it?
If you would want to keep it, then why not keep the ascending sort when they ungroup?
If you would not want to keep it, then why not simply discared the sorting from any grouped columns when you ungroup?
You often start your replies like that ... hmmm.
You have a good grasp of what I am trying to do and yes I would, as I said, have to do all that you describe ...
but I would also have to somehow track the sorting that was applied by 'column header clicking' versus the sorting that was applied when a column header was dragged to the top to group.
Then I would have to use that list of keys to do the 'pre-grouping' re-sort.
Seems to me (and I may be out there) that this is some functionality that should be built in...
Hooked into the 'grouping part of the model' where there is currently only a read only field:
col.IsGroupByColumn
Your control should handle the part of the 'finagling' we both described that is required to do programmatic ungrouping and maintain previous sort values.
But hey, who am I to say.
:)
Hi Mitch,
I'm not exactly sure what you are trying to do.
But the sorting and grouping are tightly tied together and they are both handled by the SortedColumns collection on the band.
So if you want to ungroup, but still maintain the same sort order, what you would have to do is clear the SortedColumns, then re-sort the columns the way they were. So you would need to loop through the collection and record the column key and the column.SortIndicator. Then clear the collection. Then use the key and the SortIndicator to re-apply the sorting.