Hi
I have gone through several posts on this topic, but for some reason, must be missing some piece.
We have an ultragrid with many columns.
I want to programmatically set the sorting of multiple columns based on a boolean flag (yes sorts to one set of four columns; no sets to a different set.)
Is there an end to end example? I have provided the pieces I tried to put together myself.
Do I need
1. something in the ugrd_AfterSortChange or ugrd_BeforeSortChange routines?
2. ugrd_InitializeLayout routine, such as:
e.Layout.Override.HeaderClickAction = HeaderClickAction.SortMulti
3. I have the following rows set as my multi for one condition using the following syntax
ugrd.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.SortMulti
ugrd.DisplayLayout.Bands(c_bandAccounts).Columns("HistoryExistsSort").SortIndicator = SortIndicator.Ascending
ugrd.DisplayLayout.Bands(c_bandAccounts).Columns("FollowupSort").SortIndicator = SortIndicator.Ascending
ugrd.DisplayLayout.Bands(c_bandAccounts).Columns("GuarantorLastName").SortIndicator = SortIndicator.Ascending
ugrd.DisplayLayout.Bands(c_bandAccounts).Columns("AccountNumber").SortIndicator = SortIndicator.Ascending
Thank you,
- M
Hi Michael,
Setting the SortIndicator property on a column will clear the sorting on the other column. What you need to do is add to the SortedColumns collection so it's clear to the grid that you mean to add a column instead of just setting the sorting. Here's some sample code:
Private Sub UltraGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout Dim layout As UltraGridLayout = e.Layout Dim band As UltraGridBand = layout.Bands(0) Dim ov As UltraGridOverride = layout.Override ov.HeaderClickAction = HeaderClickAction.SortMulti band.SortedColumns.Add("Int32 1", False) band.SortedColumns.Add("String 1", False) band.SortedColumns.Add("DateTime 1", False) band.SortedColumns.Add("double 1", False) End Sub
Hi Mike,
I have a requirement to work both conditions Column selection & Column Sorting. Column/multi column selection & column sort.
Please suggest me best solution.
1. can i choose HeaderClickAction as select for column selection and for sorting implementation on mouseClick event.
2. can i choose HeaderClickAction as MultiSort for column sorting and for column selection implementation on mouseClick event.
Well, there is already a property for this: HeaderClickAction. So I suppose if you wanted to allow the user to change the behavior of clicking on a column header by holding down a modifier key, you could trap the grid's KeyDown and KeyUp and set the HeaderClickAction based on some key and then reset it when that key is released (or some other key is pressed). The Ctrl key is already used for multiple selection and I think the Shift key might also be mapped for range selection or possibly multiple sorting. So you'd have to choose some other key like maybe Alt or some other key that isn't used for anything.
But I still think it's a very strange UI and I know of no application that does such a thing. So you will have to educate your users about which key(s) to use.
we want to implement one feature at once as setting property or any standard key press on column header. Please suggest me the best process.
Hi,
I don't understand your question. Clicking on a column header can either sort the column or select the column. It can't do both at the same time. At last not via a property setting.
If you want it to do both at once, then I suppose you could handle the clicking yourself in code and then both select and sort the column programmatically.But frankly, that would be a very strange an unintuitive user interface.
HOWTO:UltraWinGrid Mouse Position and Column Identification