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
175
How to do a simple binding of the ultrawintree
posted

I am getting really frustrated now, for a the last few hours looking for a simple way to do data binding on the tree.

Let's say I have a dtNodes as datatable.

Now I want to specify the column that will represent the Key of the node. and nother column that will represent the Text of the node, and the last one the Tag of the node. how do I specify this when doing data binding at run time. The coed below doesn't work.

And then finally based on the other values of the columns in the dtNodes I want to change the look of the individual nodes, I guess this shouldn't be so complicated.

treeGateways.DataSource = dtNodes;
treeGateways.NodeLevelOverrides[0].ColumnSet.NodeTextColumn = treeGateways.NodeLevelOverrides[0].ColumnSet.Columns["HubName"];
treeGateways.NodeLevelOverrides[0].ColumnSet.Key = "HubID";

Please help, I am going crazy over this.

thanks

 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    If you bind the tree to data source, the tree will display as a grid by default. So NodeTextColumn won't have any effect in this mode.

    If you want the tree to display as a regular tree, without columns, then you have to set the Style to Standard.

    Once you do that, the NodeTextColumn will allow you to set which column in the ColumnSet the node will display as it's text. But I'm not sure using NodeLevelOverrides[0] will have any effect here, because that might not be the ColumnSet that is being used.

    I'd recommend using the ColumnSetGenerated event, instead - assuming you are letting the tree generate the ColumnSets and not creating them yourself. 

    Regarding the Key and the Tag, there's no property to automatically assign these properties on a node. But you could handle the InitializeDataNode event and set it yourself. The thing to do is to get the ListObject on each node. This will return the underlying object from the data source. In this case, it's probably a DataRowView, so you can use the Row property to get the DataRow and then get teh values of whatever fields you want from there. 

    InitializeDataRow is also a good place to assign the LeftImages/RightImages. This once again assumes you are using Standard Style - these properties are ignored in the grid Style.

     

Children
No Data