Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
UltraTree: mix of columnsets (ragged hierarchy)
posted

Hi,

I'd like to display a hierarchy of the following structure in an unbound (=code-drawn) UltraTree.

  • I have 4 datepart nodes which are subordinated in the usual way: year, halfyear, quarter, month.
  • Each of these datepart nodes may contain subnodes for requirements, as well as the single "child datepart node" for year, halfyear and quarter (month has no child datepart node)
  • For the 4 datepart nodes, there's a uniform columnset (of. say, 3 columns)
  • For the requirements' nodes, there's a different uniform columnset (of, say, 8 columns)
  • The datepart nodes should always be the first child of its parent, so that its descendants can be collapsed: "year requires year's requirements plus the halfyear's and its descedants. I can collapse the halfyear to see only year-specific requirements".

So, this could look that way:

Year
Halfyear
Quarter
Month
MonthRequirement1
MonthRequirement2
QuarterRequirement1
QuarterRequirement2
QuarterRequirement3
HalfyearRequirement1
HalfyearRequirement2
HalfyearRequirement3
YearRequirement1
YearRequirement2

I've built two columnsets, colsetDatepart and colsetRequirement, but the UltraTree view style strikes back:

  • set to OutlookExpress, all columns have the same headers 
  • set to Grid, each Node gets its own header . The usual remedy here is giving the parent's nodes collection a single constant columnset instead of assigning the same columnset to each node. But here, the parent-nodes need to have two distinct columnsets. So, thats no way either.

What can I do? Any hint appreciated.

Thanks

Martin

  • 1700
    Offline posted

    Hello Martin,

    Two different column sets could be used for sibling notes, however instead of overriding the column set of the child collection of the parent node, what you would need to do is overriding the columnSet property of the node itself. It could be done with the following code:

    childNode.Override.ColumnSet = columnSet1;

    This code would affect only the node and not its siblings so each sibling can have a different column set. For example, the Year node can have Half year child node with colsetDatepart, while the YearRequirement nodes can have the colsetRequirement.

    Below I am pasting a code snippet that demonstrates what I have explained above, it demonstrates how parent node can have child nodes with different column sets, the code covers only 2 level hierarchy, however the logic for all the other levels is exactly the same to the logic used with 2 level hierarchy.

     

    this.ultraTree1.ViewStyle = ViewStyle.FreeForm;
                UltraTreeNode parentNode1 = this.ultraTree1.Nodes.Add("Year");
    
                UltraTreeColumnSet columnSet1 = new UltraTreeColumnSet();
                columnSet1.Columns.Add("Name");
                columnSet1.Columns.Add("A");
                columnSet1.Columns.Add("B");
                columnSet1.Columns.Add("C");
    
                UltraTreeColumnSet columnSet2 = new UltraTreeColumnSet();
                columnSet2.Columns.Add("Name");
                columnSet2.Columns.Add("1");
                columnSet2.Columns.Add("2");
               
                UltraTreeNode childNode = parentNode1.Nodes.Add();
                childNode.Override.ColumnSet = columnSet2;
                childNode.Cells["Name"].Value = "Half Year";
                childNode.Cells["1"].Value = "11";
                childNode.Cells["2"].Value = "21";
                childNode.Cells["Name"].Column.AutoSizeMode = ColumnAutoSizeMode.AllNodes;
    
                childNode = parentNode1.Nodes.Add();
                childNode.Override.ColumnSet = columnSet1;
                childNode.Cells["Name"].Value = "YearRequirement1";
                childNode.Cells["A"].Value = "A1";
                childNode.Cells["B"].Value = "B1";
                childNode.Cells["C"].Value = "C1";
                childNode.Cells["Name"].Column.AutoSizeMode = ColumnAutoSizeMode.AllNodes;
    
                childNode = parentNode1.Nodes.Add();
                childNode.Override.ColumnSet = columnSet1;
                childNode.Cells["Name"].Value = "YearRequirement2";
                childNode.Cells["A"].Value = "A2";
                childNode.Cells["B"].Value = "B2";
                childNode.Cells["C"].Value = "C2";
                childNode.Cells["Name"].Column.AutoSizeMode = ColumnAutoSizeMode.AllNodes;
    
                this.ultraTree1.ExpandAll();

    I am also attaching a screenshot that demonstrates how would the tree look, when there are sibling nodes with different column sets.

     

    Please let me know if you have any questions.

    Regards,
    Ivan Kitanov