Data not populating on expand - several tables at a level

14 posts, 1 answers
  1. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 01 Aug Link to this post

    I am using the exact example as shown here -http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/hierarchical-grid-types-and-load-modes/several-tables-at-a-level 

    I am using SeverOnDemand on Master and DetailTables. 

    Using below line in RadGrid1_DetailTableDataBind(), all the rows in the masterTable gets expanded on click of the Expand toggle button.

     RadGrid1.MasterTableView.HierarchyDefaultExpanded = True
    e.DetailTableView.HierarchyDefaultExpanded = True

     

    How to make the row expand or collapse on toggle sever side?

     

    Any help is appreciated. Thanks.

  2. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 02 Aug Link to this post

    Any one ?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 04 Aug Link to this post

    Hi,

    The following approach works properly for me:
    protected void CollapseAllClick(object sender, EventArgs e)
    {
    RadGrid1.MasterTableView.HierarchyDefaultExpanded = false;
    RadGrid1.Rebind();
    // If you not used Advance data binding then again Bind // RadGrid1.DataSource = ""; RadGrid1.DataBind();
    }
    protected void ExpandAllClick(object sender, EventArgs e)
     {
    RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;
    RadGrid1.Rebind();
    // If you not used Advance data binding then again Bind // RadGrid1.DataSource = ""; RadGrid1.DataBind();
    }

    Please check your code and see if any errors appear when this code is executed that might prevent the expand.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  5. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 04 Aug in reply to Maria Ilieva Link to this post

    Hi Maria,

    Thanks for the reply. I am able to expand - click on a single expand button expands all the rows, as I have the RadGrid1.MasterTableView.HierarchyDefaultExpanded = True
                e.DetailTableView.HierarchyDefaultExpanded = True

    in RadGrid1_DetailTableDataBind()

    I want to expand a single selected row and collapse the same on clicking the toggle button.

    Also, where should I call these funs - CollapseAllClick and ExpandAllClick

     

    Thanks.

  6. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 04 Aug in reply to Maria Ilieva Link to this post

    I also tried this demo on Grid - Hierarchy with Templates - http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/hierarchy-with-templates/defaultvb.aspx?show-source=true

    I am facing the same problem again, I couldn't toggle expand or collapse (server side).

    All i get is the expanded first row on load, as in RadGrid1_PreRender() 

    If Not Page.IsPostBack Then
                    RadGrid1.MasterTableView.Items(0).Expanded = True
                    RadGrid1.MasterTableView.Items(0).ChildItem.FindControl("InnerContainer").Visible = True
    End If

  7. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 04 Aug Link to this post

    Okay, I found where I get hit.

    This one is  Grid - Hierarchy with tempaltes.

    I am using filterCombos in the radgrid. Without filters, eveything works fine. But whenever I filter either the inbuilt filer or the filter combos, radgrid.rebind is called and then the toggle stops working. Any ideas ????

     Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs) Handles RadGrid1.PreRender
            Dim filterExp As String = RadGrid1.MasterTableView.FilterExpression.ToString()
            If filterExp <> "" Then
                filterExp = Replace(filterExp.ToUpper, "[", "")
                filterExp = Replace(filterExp, "]", "")
                RadGrid1.MasterTableView.DataSource = Nothing
                RadGrid1.MasterTableView.Rebind()
            End If      
        End Sub

     Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles RadGrid1.ItemCommand
            If TypeOf e.Item Is GridCommandItem Then
                If e.CommandName = "InitShowAll" Then
                    RadGrid1.MasterTableView.FilterExpression = String.Empty
                    For Each column As GridColumn In RadGrid1.MasterTableView.RenderColumns
                        If TypeOf column Is GridBoundColumn Then
                            Dim boundColumn As GridBoundColumn = TryCast(column, GridBoundColumn)
                            boundColumn.CurrentFilterValue = String.Empty
                        End If
                    Next
                    RadGrid1.MasterTableView.Rebind()
                End If
            End If
            If e.CommandName = RadGrid.ExpandCollapseCommandName AndAlso TypeOf e.Item Is GridDataItem Then
                DirectCast(e.Item, GridDataItem).ChildItem.FindControl("InnerContainer").Visible = Not e.Item.Expanded
            End If
        End Sub
        Protected Sub RadGrid1_ItemCreated(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemCreated
            If TypeOf e.Item Is GridNestedViewItem Then
                e.Item.FindControl("InnerContainer").Visible = DirectCast(e.Item, GridNestedViewItem).ParentItem.Expanded
            End If
        End Sub

     

    Thanks

  8. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 09 Aug Link to this post

    Hello,

    You can set the RetainExpandStateOnRebind property of the grid, it gets or sets a value indicating if the Expanded property of both hierarchy and group items will be retained after a call to Rebind() or Rebind() method.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  9. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 09 Aug in reply to Maria Ilieva Link to this post

    Hi Maria, 

    I already have RetainExpandStateOnRebind="true"  in the parent RadGrid and also in the Radpageview radGrids. But it is not working. I have attached the before and after filtering screen shots. You can see the toggle icon is shown as expanded but there is no grid visible. I even tried closing the row and expanding it again. Still nothing.

    <MasterTableView CommandItemDisplay="Top" DataKeyNames="TASK_ID" CssClass="table" ClientDataKeyNames="TASK_ID, STATUS" TableLayout="Auto" HorizontalAlign="NotSet" AutoGenerateColumns="false" RetainExpandStateOnRebind="true" HierarchyLoadMode="ServerOnDemand" AllowFilteringByColumn="true" AllowMultiColumnSorting="True">

    In Grid PreRender, I am calling the Rebind().

     Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs) Handles RadGrid1.PreRender
            Dim filterExp As String = RadGrid1.MasterTableView.FilterExpression.ToString()
            If filterExp <> "" Then
                filterExp = Replace(filterExp.ToUpper, "[", "")
                filterExp = Replace(filterExp, "]", "")
                RadGrid1.MasterTableView.DataSource = Nothing
                RadGrid1.MasterTableView.Rebind()
            End If
    End Sub

    Thanks.

  10. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 09 Aug in reply to Maria Ilieva Link to this post

    I have RadGrid1_NeedDataSource() for the main grid, and declarative binding for the nested radgrids. Where should rebind? 

    Protected Sub RadGrid1_ItemCreated(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemCreated

            'BELOW LINES: if comment these lines - filter works for outer grid and not for inner grid; if uncommented - filter works for inner and not for outer grid. What piece of code am I missing ?
            If TypeOf e.Item Is GridNestedViewItem Then
                e.Item.FindControl("InnerContainer").Visible = DirectCast(e.Item, GridNestedViewItem).ParentItem.Expanded
            End If
        End Sub

    Thanks.

  11. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 10 Aug Link to this post

    Looks like same issue that was discussed here but i couldn't find a solution yet  -http://www.telerik.com/forums/nestedviewtemplate-and-filtering

  12. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 10 Aug in reply to Maria Ilieva Link to this post

    Update:

    The parent filter works.  I removed the Parent RadGrid1_ItemCreated() and  I updated the Parent Prerender, but I couldn't perform expand/filter/sort in the inner grid after filtering the Parent grid.

    Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs) Handles RadGrid1.PreRender
            Dim filterExp As String = RadGrid1.MasterTableView.FilterExpression.ToString()
            If filterExp <> "" Then
                filterExp = Replace(filterExp.ToUpper, "[", "")
                filterExp = Replace(filterExp, "]", "")
                RadGrid1.MasterTableView.DataSource = Nothing

                LoopHierarchyRecursive((RadGrid1.MasterTableView))         
            End If    
        End Sub

     Protected Sub LoopHierarchyRecursive(ByVal gridTableView As GridTableView)
            gridTableView.Rebind()

            For Each nestedViewItem As GridNestedViewItem In gridTableView.GetItems(GridItemType.NestedView)
                nestedViewItem.FindControl("InnerContainer").Visible = DirectCast(nestedViewItem, GridNestedViewItem).ParentItem.Expanded 
                If nestedViewItem.NestedTableViews.Length > 0 Then
                    LoopHierarchyRecursive(nestedViewItem.NestedTableViews(0))
                End If
            Next
        End Sub

     

    This is so frustrating.

    It would be really helpful if i can get a sample code for Grid - Hierarchy with Templates , with filters in both outer and inner grids.

  13. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 12 Aug Link to this post

    Hello,

    You should not call Rebind() or setting DataSource to Nothing in the PreRender event as this is causing recreating all grid items, which is returning them to their initial state. In this case all items are collapsed.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  14. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 19 Aug in reply to Maria Ilieva Link to this post

    That worked(for now). Thanks Maria.

     

  15. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 24 Aug Link to this post

    Hello Subhashini,

    I'm glad that the provided solution works for you. Do not hesitate to contact us in case further assistance is needed.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017