Topic: Collapse and expand

Hi all,

Could somebody provide script for keeping original status of tree nodes after adding new nodes please?


If I collapsed some tree nodes on form1 then added new tree top or child node, collapsed nodes stays collapsed after saving newly added node. Currently, after adding new node all tree nodes expands.


I attached one of Derek's sample project.

Post's attachments

Attachment icon TreeClollapseExpand.zip 6.32 kb, 123 downloads since 2022-06-10 

Adam
God... please help me become the person my dog thinks I am.

Re: Collapse and expand

Hi Adam,
Sorry for the delay - it's been ages since I last used 'treeview' and it took a while to remember how it all hangs together.
Try doing it like this (please see attached).
Regards,
Derek.

Post's attachments

Attachment icon treeview add.zip 337.99 kb, 125 downloads since 2022-06-12 

Re: Collapse and expand

Hi Derek,


Thank you very much.....
Truly appreciated.......


Would it be possible to keep user tree status after adding new tree item.
i.e. If I have a 1111 node expanded and I'm adding a child to node 2222; after saving it node 1111 and node 2222 would stay expanded.
No worries if it's not feasible. I'm extremely grateful to you for all your kind and first class help.

Adam
God... please help me become the person my dog thinks I am.

Re: Collapse and expand

Hi Adam,
I guess you could try something like the attached (which I think gives you what you're asking about);  it uses a status flag to remember what nodes have been opened.
By way of explanation,
1.  the 'collapse' button collapses the treeview
2.  the 'expand all' expands the treeview irrespective of what you've been working on
3.  the 'expand session' expands all the nodes that you have worked on during the current session
4.  the 're-set session' clears the flags
You might want to consider using 'beginsqlitetransaction' and 'commitsqlitetransaction' to speed up the re-drawing of the treeview if you have a lot of nodes - I vaguely remember some of the treeview stuff I looked at a couple of years back as being rather slow (I didn't bother putting it in the attachment as I don't know what volumes you have).
I couldn't think of any other approach but maybe others might have some ideas.
Anyway, hope this helps or gives you some pointers.
Derek.

Post's attachments

Attachment icon treeview selected expand.zip 339.62 kb, 153 downloads since 2022-06-12 

Re: Collapse and expand

Hi Derek,


Thank you very much.....
Truly appreciated.......

Adam
God... please help me become the person my dog thinks I am.