TreeList first cell columnspan problem

4 posts, 2 answers
  1. Daniel
    Daniel avatar
    11 posts
    Member since:
    Oct 2011

    Posted 18 Feb 2013 Link to this post

    Hello.

    I have dinamically created a treeList. I add a new header item and I want the first cell to be merged with the following cells. Even if I set colspan to the cell, after rendering in page, the cell will always have colspan 2.
    // Initialize the first header
    var headerItemGrayLine = new TreeListHeaderItem(RadTreeListLocations, TreeListItemType.HeaderItem, false);

    // Adding cells
    headerItemGrayLine.Cells.Add(
    new TreeListTableHeaderCell { ColumnSpan = 13, Height = 50, BackColor = LocationColor, BorderWidth = 0});
    for (int i = 1; i < 13; i++)
    {
      headerItemGrayLine.Cells.Add(new TreeListTableHeaderCell { ColumnSpan = 0, Height = 50, BackColor = LocationColor, BorderWidth = 0, Visible = false });
    }

    What am I missing? I attach a picture to see better what is the problem.

    Thank you,
  2. Answer
    Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 21 Feb 2013 Link to this post

    Hi Daniel,

    Thank you for contacting us.

    You could achieve your scenario by inserting a hidden dummy first cell so the column span will be applied on the first cell invisible cell.
    // Initialize the first header
    var headerItemGrayLine = new TreeListHeaderItem(RadTreeList1, TreeListItemType.HeaderItem, false);
     
    TreeListTableHeaderCell cell = new TreeListTableHeaderCell();
    cell.Style.Add(HtmlTextWriterStyle.Display, "none");
    headerItemGrayLine.Cells.Add(cell);
    // Adding cells
    headerItemGrayLine.Cells.Add(new TreeListTableHeaderCell { ColumnSpan = 13, Height = 50, BackColor = Color.Aqua, BorderWidth = 0 });
    for (int i = 1; i < 13; i++)
    {
        headerItemGrayLine.Cells.Add(new TreeListTableHeaderCell { ColumnSpan = 0, Height = 50, BackColor = Color.Red, BorderWidth = 0, Visible = false });
    }


    All the best,
    Antonio Stoilkov
    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. Daniel
    Daniel avatar
    11 posts
    Member since:
    Oct 2011

    Posted 25 Feb 2013 Link to this post

    Hello,

    I implemented this solution. Now, when I expand the tree, the header is missing columns at the end. I guess I need to adjust the column span by the level of expansion of the tree. How can I find this level?

    Thank you
  5. Answer
    Antonio Stoilkov
    Admin
    Antonio Stoilkov avatar
    530 posts

    Posted 28 Feb 2013 Link to this post

    Hi Daniel,

    You could find the expansion level by using the code provided below. The idea is to get the max NestedLevel from the RadTreeList Items.
    int expansionLevel = this.RadTreeList1.Items.Max(i => (i as TreeListDataItem).HierarchyIndex.NestedLevel);

    All the best,
    Antonio Stoilkov
    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.
Back to Top