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

TreeList first cell columnspan problem

3 Answers 191 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Attila
Top achievements
Rank 1
Attila asked on 18 Feb 2013, 02:04 PM
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,

3 Answers, 1 is accepted

Sort by
0
Accepted
Antonio Stoilkov
Telerik team
answered on 21 Feb 2013, 01:36 PM
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.
0
Attila
Top achievements
Rank 1
answered on 25 Feb 2013, 12:35 PM
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
0
Accepted
Antonio Stoilkov
Telerik team
answered on 28 Feb 2013, 06:41 AM
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.
Tags
TreeList
Asked by
Attila
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Attila
Top achievements
Rank 1
Share this question
or