Showing results for 
Search instead for 
Do you mean 
Solved! Go to solution

insert a node in treelist in specific order

Dear all
I am trying to insert a node into a TreeListMenu. It can successfully add nodes into a tree, at different level - using parent and child relationship. The function I am using is:

this->tree_control0->InsertNode(CurrentNOde, ParentNode, NULL, Tree::NodeInsertOptionAlwaysFirst); 

However, the order of the nodes within the same level goes as the default order, no matter how I insert them. For example, if I would like to list a tree as (L0=level 0, L1=level 1):
  L0: a
        L1: b
        L1: c
  L0: d

where 'a' and 'b' are parent nodes, but 'b' and 'c' are child nodes of node 'a'. The problem is, no matter I insert 'b' first or 'c' first, it will always be displayed as 'c' listed after 'b'. This seems to follow apathetic order. (if I change the name of 'b' to be 'm' for example, the list will automatically updated as 'm' after 'c' in Level 1(L1).

Could anyone suggest a method that I may list the tree nodes in the way the user wanted but rather than default? I tried to change the option 'NodeInsertOptionAlwaysFirst' as other options, it doesn't help.

Many thanks

Accepted by topic author lugan2
‎11-03-2015 11:51 AM

Re: insert a node in treelist in specific order

After you have added your column to your tree list you can set the sorting option for that column.

I have a feeling the default is sorted ascending, but you can choose unsorted, in which case I expect the nodes will appear in the order they are added.

From memory you have to do something like:

nxTree.setColumnSortOption(columnId, ColumnSortOption.UNSORTED)
Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5

Re: insert a node in treelist in specific order

Thanks Graham. What you have said makes a perfect sense. After attempting some changes to the code, now the tree nodes are inserted according to the insertion sequence. Two changes I made are:

   1.  this->tree_control0->SetColumnSortOption(assName, Tree::ColumnSortOptionUnsorted); //set the column insertion option as "ColumnSortOptionUnsorted".

   2.  this->tree_control0->InsertNode(currentnode, parentnode, NULL, Tree::NodeInsertOptionLast); //Set the node insertion option as "NodeInsertOptionLast".


Many thanks again!