Generate Hierarchy Grid View with multiple levels

8 posts, 0 answers
  1. Đạt
    Đạt avatar
    3 posts
    Member since:
    Dec 2014

    Posted 02 Nov Link to this post

    Hello all,

    I want to generate hierarchy grid view with multiple levels like the picture http://screencast.com/t/L0snTsuj

    Currently i use AutoGenerateHierarchy and create recursive data, i generated three levels like the picture http://screencast.com/t/ZtxNcwMqPaz

    However i could not found any solutions for latest children template (different columns and data, grouping by columns, and only generate when parent expanded)

    Please help me!!!

    Thanks
    Regards

  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 03 Nov Link to this post

    Hello Dat,

    Thank you for writing.  

    I would like to note that when you setup grid hierarchy, you add a template which is common for the entire child level. Hence, it uses common columns. However, in order to achieve your goal, you can add several child templates and display the relevant one (and hide the other/s) when expanding a master row. A sample approach is demonstrated in our Formatting Cells help article >> Example 4: Hiding child tabs when no data is available section.

    As to the grouping question, note that you can add a GroupDescriptor programmatically to the desired child GridViewTemplate. The following help article is quite useful on this topic: http://docs.telerik.com/devtools/winforms/gridview/grouping/setting-groups-programmatically

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Đạt
    Đạt avatar
    3 posts
    Member since:
    Dec 2014

    Posted 06 Nov in reply to Dess Link to this post

    Hi Dess,

    Thanks for your helps!

    However i think it so difficult implement and custom because everything are dynamic, so i use TableLayoutPanel to custom it.

    Thanks
    Regards
    Dat

  5. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 07 Nov Link to this post

    Hello Đạt, 

    Thank you for writing back. 

    Feel free to use this approach which suits your requirements best. However, the recommended approach is to use two different child templates with the respective columns and show only one of the child templates at a time for the given parent row.

    If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  6. Đạt
    Đạt avatar
    3 posts
    Member since:
    Dec 2014

    Posted 16 Nov in reply to Dess Link to this post

    Hi Dess,

    Thanks for your helps!

    Thanks
    Regards
    Dat

  7. Martin
    Martin avatar
    2 posts
    Member since:
    Jun 2012

    Posted 3 days and 8 hours ago in reply to Dess Link to this post

    Hi. I used the example Formatting Cells help article >> Example 4: Hiding child tabs when no data is available section.
    But I have a problem, while hiding the tab that has no data, sometimes expands several rows at the same time, but in isolation, I can not find the pattern of error.

    Thank you very much, excuse the English, is a translator, I speak Spanish.
  8. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 2 days and 17 hours ago Link to this post

    Hello Martin,

    Thank you for writing.  

    Would it be possible to provide a full code snippet reproducing the problem you are facing? In addition, a sample screenshot of the obtained and expected result would help us better understand the issue. A better option is to submit a support ticket where you can provide a sample project reproducing the problem.

    Once we replicate the issue locally, we would be able to investigate the precise case and assist you further. Thank you in advance.

    I am looking forward to your reply.

    Regards,
    Dess
    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
  9. Martin
    Martin avatar
    2 posts
    Member since:
    Jun 2012

    Posted 2 days and 6 hours ago in reply to Dess Link to this post

    Hi Dess, thanks for the reply.

    The code used is a copy of the example:
    Private Sub radGridView1_ViewCellFormatting(sender As Object, e As CellFormattingEventArgs)
        Dim cell As GridDetailViewCellElement = TryCast(e.CellElement, GridDetailViewCellElement)
        Dim expanderCell As GridGroupExpanderCellElement = TryCast(e.CellElement, GridGroupExpanderCellElement)
        If expanderCell IsNot Nothing AndAlso TypeOf e.CellElement.RowElement Is GridDataRowElement Then
            Dim hierarchyRow As GridViewHierarchyRowInfo = DirectCast(expanderCell.RowInfo, GridViewHierarchyRowInfo)
            If Not IsExpandable(hierarchyRow) Then
                expanderCell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Hidden
            Else
                expanderCell.Expander.Visibility = Telerik.WinControls.ElementVisibility.Visible
            End If
        ElseIf cell IsNot Nothing Then
            Dim hierarchyRow As GridViewHierarchyRowInfo = DirectCast(DirectCast(cell.RowInfo, GridViewDetailsRowInfo).Owner, GridViewHierarchyRowInfo)
            For i As Integer = 0 To cell.PageViewElement.Items.Count - 1
                Dim item As RadPageViewItem = cell.PageViewElement.Items(i)
                Dim viewInfo As GridViewInfo = hierarchyRow.Views(i)
                item.Text = "Child Template " & i
                If viewInfo.ChildRows.Count = 0 Then
                    If i = 0 AndAlso i < cell.PageViewElement.Items.Count - 1 Then
                        cell.PageViewElement.Items(i + 1).IsSelected = True
                    End If
                    item.Visibility = Telerik.WinControls.ElementVisibility.Collapsed
                Else
                    item.Visibility = Telerik.WinControls.ElementVisibility.Visible
                End If
            Next
        End If
    End Sub
    Private Function IsExpandable(hierarchyRow As GridViewHierarchyRowInfo) As Boolean
        For Each view As GridViewInfo In hierarchyRow.Views
            If view.ChildRows.Count > 0 Then
                Return True
            End If
        Next
        Return False
    End Function


    I attach a gif image where you can see how RadGrid expands two or more rows when clicking.

     

    Thank you very much

    Martin.

Back to Top
UI for WinForms is Visual Studio 2017 Ready