TreeModel insert node

Hi,

how can I insert a new node in a treemodel at a specific index and at runtime?

e.g: insert CHILD_03 at runtime

<span =“Apple-tab-span” style=“white-space:pre”> CHILD_01
PARENT CHILD_02
<span =“Apple-tab-span” style=“white-space:pre”> CHILD_04

Thank you
Axel

In a TreeModel you just get to specify the parent node’s key, not the ordering of the children.

If you are using TreeLayout, you can set the TreeLayout.sorting and .comparer properties (and alternateSorting and alternateComparer, depending on the treeStyle) in order to make sure the children are ordered the way that you want. Your custom comparer function will be passed two TreeVertexes – call them a and b. You can get your model data via:a.node.data

Hi walter,

could you pls provide an example for the comparer function?

you create a market childnode by clicking on a listview item. the listview is index based. the diagram’s childnodes must have the same order as the listview.

You can find an example by searching the sources, such as: the Pipes sample.