SharpGrid Support

Started by deepti54 at 08-17-2006 7:47 AM. Topic has 2 replies.

Print Search Rate
Sort Posts:    
   08-17-2006, 7:47 AM
deepti54 is not online. Last active: 8/11/2006 9:15:57 PM deepti54

Not Ranked
Joined on 07-24-2006
Posts 21
Grouping Issue.

Hi

In my application if I group my data on one columns say "Col1".Now I go and sort my data on the same column "Col1".

The resulting grid has all the groups collapsed, I want that it should maintain the same status as it has before applying sorting.

i.e if some groups are collapsed while others are expanded, so the resulttant grid (after sorting)should show the same .

 

Please suggest.

Regards

Deepti


   Report 
   08-17-2006, 10:46 AM
ericc is not online. Last active: 4/4/2009 4:32:14 PM ericc

Top 10 Posts
Joined on 03-01-2005
Posts 1,857

DDStaff
Re: Grouping Issue.

deepti54,
                Thank you for your question. SharpGrid does not offer an inherent way to keep track of all columns expand / collapse states. The way to approach this would be through the use of some custom code (which saves the expand collapse state before the sort, and applies it to the grid after the sort).

The link below contains some information about Controlling Group Expansion/Collapse through Code.
http://www.datadynamics.com/forums/78644/ShowPost.aspx

Please let me know if I can be of further assistance. Thank you!

 


   Report 
   03-18-2009, 10:33 AM
pryan is not online. Last active: 3/18/2009 11:17:27 PM pryan

Not Ranked
Joined on 10-21-2004
Posts 4
Re: Grouping Issue.

I wrote a few procedures to persist and restore the grouped states. Hope this helps.  Not sure why it was never incorporated into the control.  When you sort on the grouped column or when you refresh a bound grid it loses the expand\collapsed states.

Hope this Helps....

 

Dim arExpanded() As String   'In General Declarations

Private Sub SGGrid1_BeforeClickSort(ByVal ColIndex As Long, CancelSort As Boolean)

    If SGGrid1.Groups.Count = 0 Then Exit Sub
    'I am only allowing grouping on one column at a time. You could iterate through the groups collection and check for match on the GroupingColumn
    If SGGrid1.Groups(1).GroupingColumn = SGGrid1.Columns(ColIndex).Key Then
        PersistGroupState
    End If
   
End Sub

Private Sub SGGrid1_AfterClickSort(ByVal ColIndex As Long)

    If SGGrid1.Groups.Count = 0 Then Exit Sub
   'I am only allowing grouping on one column at a time. You could iterate through the groups collection and check for match on the GroupingColumn.

    If SGGrid1.Groups(1).GroupingColumn = SGGrid1.Columns(ColIndex).Key Then
        RestoreGroupState
        SGGrid1.Redraw
    End If
   
End Sub

Sub PersistGroupState()

Dim row As sgRow, i As Integer

Erase arExpanded

For Each row In SGGrid1.Rows
    If row.Type = sgGroupHeader Then
        If row.GroupHeading.Expanded Then
            i = i + 1
            If i = 1 Then ReDim arExpanded(0)
            ReDim Preserve arExpanded(i)
            arExpanded(i) = NoNull(row.GroupHeading.GroupingValue) ' row.Key
        End If
    End If
Next

End Sub


Sub RestoreGroupState()

Dim row As sgRow
Dim i As Integer

On Error GoTo ErrorHandler

    For i = 1 To UBound(arExpanded)
        For Each row In SGGrid1.Rows
            If row.Type = sgGroupHeader Then
                If NoNull(row.GroupHeading.GroupingValue) = arExpanded(i) Then
                    row.GroupHeading.Expand
                End If
            End If
        Next
    Next

ErrorHandler:
'Array Not initialized will generate an error
End Sub


   Report 
GrapeCity » Product Support » SharpGrid Suppo... » Grouping Issue.

Privacy Policy | Copyright © 1997-2012 — GrapeCity, inc.
All trademarks mentioned are the property of their respective owners.