TreeList showing footers only for first level of hierarchy

4 posts, 0 answers
  1. JFB
    JFB avatar
    6 posts
    Member since:
    Oct 2012

    Posted 12 Apr 2012 Link to this post

    I have a TreeList that contains a grid of values and I want to display a single footer at the end of the TreeList for showing the column totals for all columns that have a FooterTemplate.

    Note that the TreeList footers on Telerik's website have multiple levels for each hierarchy level. I would like to hide the footers doing something like this, but it's not working: 

    protected void rtlRshItems_ItemDatabound(object sender, TreeListItemDataBoundEventArgs e)
       
    {
           
    TreeListDataItem item = e.Item as TreeListDataItem;

           
    if (e.Item is TreeListDataItem)
           
    {
               
    var workItemId = (int) item.GetDataKeyValue("WorkItemId");
                parentId
    = GetParentId(workItemId);

               
    if (parentId == null)
                    item
    .OwnerTreeList.ShowFooter = true;
               
    else
                    item
    .OwnerTreeList.ShowFooter = false;
           
    }
       
    }

    Note that GetParentId() returns null if there is no parent for the current item, meaning that I want to show a footer for that level only. 
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 18 Apr 2012 Link to this post

    Hello,

    You could try the following approach:
    protected void RadTreeList1_ItemCommand(object sender, TreeListCommandEventArgs e)
        {
            if (e.CommandName == "ExpandCollapse")
            {
                TreeListDataItem dataItem = e.Item as TreeListDataItem;
                if (dataItem.ParentItem != null)
                {
                    item.OwnerTreeList.ShowFooter = false;
                 }        
               else    
                 {
                    item.OwnerTreeList.ShowFooter = true;
                 }
            }
        }


    Greetings,
    Maria Ilieva
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 10 Sep 2013 Link to this post

    Same question as thread starter.
    But his code and the suggestion only toggles the showfooter property for the entire treelist...
    Any way of only showing only one footer, ignoring all hierarchy items?

    http://demos.telerik.com/aspnet-ajax/treelist/examples/columns/aggregates/defaultcs.aspx
    Count: 98 Sum: 10,702,470,081.00 Sum: 212,404,936.00 km2
    But not the partial ones if you expand items in that demo.
  5. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 10 Sep 2013 Link to this post

    Ok, 1 minute later, here's an answer that works...
                ElseIf TypeOf (e.Item) Is TreeListFooterItem Then
                    Dim tlfi As TreeListFooterItem = e.Item
                    Dim hI As TreeListHierarchyIndex = tlfi.HierarchyIndex
                    Dim a As Integer = hI.LevelIndex
                    Dim b As Integer = hI.NestedLevel
                    If a = -1 And b = -1 Then
                        tlfi.Visible = True
                    Else
                        tlfi.Visible = False
                    End If

    (ItemDatabound event)
Back to Top