Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Multi Sorted columns programmatically Ultragrid
posted

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

Parents
  • 469350
    Verified Answer
    Offline posted

    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

Reply Children