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

TreeList showing footers only for first level of hierarchy

3 Answers 136 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
JFB
Top achievements
Rank 1
JFB asked on 12 Apr 2012, 08:08 PM
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. 

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 18 Apr 2012, 08:54 AM
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.
0
Nicolaï
Top achievements
Rank 2
answered on 10 Sep 2013, 09:15 AM
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.
0
Nicolaï
Top achievements
Rank 2
answered on 10 Sep 2013, 09:28 AM
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)
Tags
TreeList
Asked by
JFB
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Nicolaï
Top achievements
Rank 2
Share this question
or