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
560
UltraWinGrid - How do I save and restore whether or not a user defined group is open
posted

I have an UltraWinGrid that gets loaded with data every time the user clicks on a refresh button.  The new data is loaded into the UltraWinGrid by setting the DataSorce member to a new DataTable each time.

The grid is set up to allow the user to group the columns, sort on columns, or filter data using any of the columns.  I need to preserve the grouping, sorting, and filtering.  I have succeeded at doing that using the following methods:

Private sortIndicator As List(Of Infragistics.Win.UltraWinGrid.SortIndicator)
Private filterConditions As List(Of Infragistics.Win.UltraWinGrid.FilterConditionsCollection)
Private isGroupByColumn As List(Of Boolean)

Private Sub GetFlatColumnSortOrder()

  Dim columnCount As Integer = grdServer.DisplayLayout.Bands(0).Columns.Count
  If (columnCount > 0) Then
    sortIndicator = New List(Of SortIndicator)(columnCount)
    filterConditions = New List(Of Infragistics.Win.UltraWinGrid.FilterConditionsCollection)
    isGroupByColumn = New List(Of Boolean)
    For index As Integer = 0 To columnCount - 1
      sortIndicator.Add(grdServer.DisplayLayout.Bands(0).Columns(index).SortIndicator)
      Dim columnFilterConditions As Infragistics.Win.UltraWinGrid.FilterConditionsCollection =           grdServer.DisplayLayout.Bands(0).ColumnFilters(index).FilterConditions
      filterConditions.Add(columnFilterConditions)
      isGroupByColumn.Add(grdServer.DisplayLayout.Bands(0).Columns(index).IsGroupByColumn)
    Next index
  End If
End Sub

Private Sub SetFlatColumnSortOrder()
  If (sortIndicator IsNot Nothing) Then
    Dim columnCount As Integer = grdServer.DisplayLayout.Bands(0).Columns.Count
    For index As Integer = 0 To columnCount - 1
       If (isGroupByColumn(index)) Then
          Dim descending As Boolean = False
          If (sortIndicator(index) = Infragistics.Win.UltraWinGrid.SortIndicator.Descending) Then
             descending = True
          End If
          grdServer.DisplayLayout.Bands(0).SortedColumns.Add(grdServer.DisplayLayout.Bands(0).Columns(index), descending, True)
       End If
       grdServer.DisplayLayout.Bands(0).Columns(index).SortIndicator = sortIndicator(index)
       grdServer.DisplayLayout.Bands(0).ColumnFilters(index).ClearFilterConditions()
       For Each fc As FilterCondition In filterConditions(index)
          grdServer.DisplayLayout.Bands(0).ColumnFilters(index).FilterConditions.Add(fc)
       Next
    Next (index)
    grdServer.DisplayLayout.Bands(0).Groups.Clear()
  End If
End Sub

GetFlatColumnSortOrder() gets called before the DataSource is set and SetFlatColumnSortOrder gets called after the DataSource is set.

Everything works fine except that the current state of the groups (whether or not they are open or closed in not being preserved.  If groups are set up by the user and the user has opened them, then after the Refresh button is pressed, the columns to be grouped appear in the group box and all filters and column sorting orders are correctly preserved, but all the groups are closed (so the user has to click on the + signs in the tree to reopen the ones he wants to be opened.

How do I save and restore the status (open/closed) of the groups?

Thanks,

Andy

Parents Reply Children
No Data