This is a migrated thread and some comments may be shown as answers.

Restore selected tab in hierarchy child page view after data refresh

1 Answer 97 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kun
Top achievements
Rank 2
Kun asked on 22 Jan 2019, 11:49 AM

Hello,

I have 3 hierarchical levels in my grid. Here is the structure:

Master template

|___tab1: Details (html view)

|___tab2: Orders (standard grid)

       |___tab2-1: Clients (standard grid)

|___tab3: Networks (standard grid)

 

I'am inspired by some posts in the forum to save and restore the expanded rows and selected rows. It works great.

I save the grid state before data refresh, and reset after data refresh. Here is the code.

Dim scrollpos As Integer = -1
Dim CurrentRow As Integer = -1
Dim expandedRows As New List(Of Boolean)()
Dim selectedRows As New List(Of Boolean)()
 
    Private Sub SaveSeletectedAndExpanded()
        scrollpos = myGridView.TableElement.VScrollBar.Value
 
        If myGridView.CurrentRow IsNot Nothing Then
            CurrentRow = myGridView.CurrentRow.Index
        End If
        If myGridView.Rows Is Nothing Then
            Exit Sub
        End If
        expandedRows.Clear()
        selectedRows.Clear()
        For i = 0 To myGridView.Rows.Count - 1
            expandedRows.Add(myGridView.Rows(i).IsExpanded)
            ' How can I remember which page tab is displayed currently?
            selectedRows.Add(myGridView.Rows(i).IsSelected)
        Next
    End Sub
 
    Private Sub RestoreSeletectedAndExpanded()
        If scrollpos <> -1 Then
            myGridView.TableElement.VScrollBar.Value = scrollpos
        End If
        If CurrentRow <> -1 Then
            myGridView.CurrentRow = myGridView.Rows(CurrentRow)
        End If
        If expandedRows IsNot Nothing Then
            For i = 0 To expandedRows.Count - 1
                myGridView.Rows(i).IsExpanded = expandedRows(i)               
            Next
        End If
        If selectedRows IsNot Nothing Then
            For i = 0 To selectedRows.Count - 1
                myGridView.Rows(i).IsSelected = selectedRows(i)
            Next
        End If
    End Sub

 

But I've found that the current selected tabbed view in the expanded row is reset to default after refresh.

How can I save the current selected tabbled view index for the expanded rows ?

 

Thank you by advanced.

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 23 Jan 2019, 11:38 AM
Hello Kung,

The GridViewHierarchyRowInfo has an ActiveView property and you can store its index within the Views collection. I am attaching my test project demonstrating a possible approach.

Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Kun
Top achievements
Rank 2
Answers by
Hristo
Telerik team
Share this question
or