Hi all,
I have some problems with a bound tree to self referencing table and ViewStyle=Standard. One problem is very basic: In all examples I have found are the dulicate root nodes set to Visible=false. After that, you can not see those nodes anymore, but they are still there!!!
If setting the node.Key Property in the InitializeDataNode-Event I got some runtime error that duplicate keys are in the tree. Removing duplicate nodes are even not allowed on bound tree's.
It looks not realy as a good solution to me handling self referencing like this. Do I'm something wrong or do I need populate the tree from code ?
My tree can have up to 5000 nodes over about 6 levels and I dont like to have duplicate nodes all around.
Thanks. Markus
Hi Mike,
I'm figuring out this right now....and it wors!!! Thanks for the good idea Mike.
Just to make the solution complete for everybody: For the relation between the root node table (contains 1 record) and the child nodes table (contains all records including root node) you have to set the relation property EnforceConstraints=FALSE because just one record in the child table (the root node record) has a parent record. Otherwise you get a exception if the relation is added to the dataset.
Thanks for your help. Markus
Yes, the first table is really a query that only contains the root-level records. So typically, in a self-referencing situation, this is all the records whose parent is null.
The second table is the whole table containing everything.
Then you have a relationship between the first table and the second. And another relationship between the second table back to itself.
That sounds interesting. Give me some time to check out this approach.
Mike Saltzman"]Basically, you would need to have your root-level table returned by a query that excludes the child data, then have a relationship between that table and the table that contains all of the data, which then has a relationship to itself.
If I understand, I need a dataSet containing two tables and I bound the table containing the root node to the tree? Expanding the root node, next level nodes get initialized?
I hope this works since I have lot of node and I have to implement resorting and searching. I maybe will run into performance issues, if the tree conatins lot of overheads.
Thanks so far. Markus
Hi Markus,
mac_swit said:I have some problems with a bound tree to self referencing table and ViewStyle=Standard. One problem is very basic: In all examples I have found are the dulicate root nodes set to Visible=false. After that, you can not see those nodes anymore, but they are still there!!!
Yes, the nodes are still there because they exist in the data source. This has nothing to do with the tree. If you don't want the root-level nodes to exist in the tree, then you would need to set up your data source accordingly. Basically, you would need to have your root-level table returned by a query that excludes the child data, then have a relationship between that table and the table that contains all of the data, which then has a relationship to itself.
mac_swit said:If setting the node.Key Property in the InitializeDataNode-Event I got some runtime error that duplicate keys are in the tree. Removing duplicate nodes are even not allowed on bound tree's.
Since you don't really care about the root-level nodes that are also child nodes, simply don't set the key on the hidden root-level nodes.Or, build your data structure such that there are no duplicates, as I described above.