Get hierarchy level and child item count

4 posts, 0 answers
  1. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 16 Apr 2013 Link to this post

    How can we determine the hierarchy level and child item count in a treelist?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Apr 2013 Link to this post

    Hi,

    Try the following code.
    C#:
    protected void RadTreeList1_ItemDataBound(object sender, Telerik.Web.UI.TreeListItemDataBoundEventArgs e)
    {
       TreeListDataItem item = e.Item as TreeListDataItem;
       int level = item.HierarchyIndex.NestedLevel;
    }
     
    protected void RadTreeList1_PreRender(object sender, EventArgs e)
    {
       foreach (TreeListDataItem item in RadTreeList1.Items)
       {
          if (item.Expanded)
          {
              int count=item.ChildItems.Count;
          }
       }
    }

    Thanks,
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 22 Apr 2013 Link to this post

    Thanks..it works.How can we use firecommand in treelist similar to radgrid?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Apr 2013 Link to this post

    Hi,

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
         RadTreeList tree = (this.FindControl("RadTreeList1") as RadTreeList);
        TreeListEditableItem item = (TreeListEditableItem)RadTreeList1.GetItems(TreeListItemType.EditItem)[0];
        item.FireCommandEvent("Update", "");
    }

    Thanks,
    Shinu
Back to Top