TreeView : parent of parent of parent of ... of item

For users of dfns, both novice and expert

TreeView : parent of parent of parent of ... of item

Postby Yves on Sun Apr 14, 2019 12:22 pm

Dear All,
with
      'bn'⎕WC'form'('coord' 'pixel')
'bn.tv'⎕WC'treeview'
depth←0 1 2 3 3 2 2 3 3 1 2 3 3 2 3 3
itm←1⊂[1]'abcdefghijklmnopqrstuvwxyz'[?((⍴depth),3)⍴26]
bn.tv.(Items Depth)←itm depth

by mouse, i select an item.
      ⍸ bn.tv.SelItems
12

i search vector of all parents from root to selected item.
by hands, i do
      bn.tv.GetParentItem 12
11
bn.tv.GetParentItem 11
10
bn.tv.GetParentItem 10
1

but, in case of all unselect
      bn.tv.SelItems
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
bn.tv.GetParentItem 0
¯1

i feel a dfns is a better solution, but i don't see how to write in dfns.
can you explain to me how to write it ?

Best Regards,
Yves
Yves
 
Posts: 38
Joined: Mon Nov 30, 2015 11:33 am

Re: TreeView : parent of parent of parent of ... of item

Postby Yves on Mon Apr 15, 2019 2:17 pm

with
      ]box on
]row on

my actual function is
      result←parentOfItem no

result←no

:Repeat
no←bn.tv.GetParentItem no
result←no,result
:Until 0=no

result←sort{(0≠⍵)/⍵}result

and result are
      parentOfItem ¨ ⍳ (⍴ bn.tv.Items)
┌─┬───┬─────┬───────┬───────┬─────┬─────┬───────┬───────┬────┬───────┬──────────┬──────────┬───────┬──────────┬──────────┐
│1│1 2│1 2 3│1 2 3 4│1 2 3 5│1 2 6│1 2 7│1 2 7 8│1 2 7 9│1 10│1 10 11│1 10 11 12│1 10 11 13│1 10 14│1 10 14 15│1 10 14 16│
└─┴───┴─────┴───────┴───────┴─────┴─────┴───────┴───────┴────┴───────┴──────────┴──────────┴───────┴──────────┴──────────┘

weakness, not very elegant...
Yves
 
Posts: 38
Joined: Mon Nov 30, 2015 11:33 am


Return to Functional Programming

Who is online

Users browsing this forum: No registered users and 0 guests