Uniface Tree Example

Author: kathy.seeman@noris.org (kathseem)

Does anyone have a sample Uniface program/form which populates a tree widget from a database table? The form I need to write will show notes made by users---date of entry, user who made entry and notes. The form will also be able to add new entriies to the database, which after stored should show in the tree. I know I need to make a tree widget and populate it in the triggers, but it's kind of confusing to read through the help and put it all together in the correct places. We run Uniface version 9.3.02. Thanks in advance for any help you can provide.

6 Comments

  1. Hi Kathy, have you fount the chapter Defining and Updating ValRep Lists for the Tree Widget in your Helpfile? each item in a tree is build from the following list: Value = ParentID !; {+ | - } NodeType !; Representation { ! T TimeStamp} for performance reasons, it is better to construct the complete valrep at first as a list-in-list: $valrep = "root=!;NODE!;root ;A=root!;NODE!;A ;B=root!;NODE!;B ;B1=B!;NODE!;B1 ;B2=B!;NODE!;B2 ;B3=B!;NODE!;B3 ;C=root!;NODE!;C" to add an item to the tree, you just have to use the following syntax: $fieldvalrep ( TreeField )= "ActionIndicator = ;" ValRepListForUpdate $valrep = "0=;NEWNODE=B3!;NODE!;new node with parent B3" Think with your 9.3 installation, you should have a "samples" directory. Maybe it's worth to have a look into tree2.zip; at least the readme looks promising.


    Author: ulrich-merkel (ulrichmerkel@web.de)
  2. Thanks, Ulrich. These examples need to be exported into a repository for me to be able to view them. From the descriptions in the Read Me files, it looks like this information will help me with what I need to do.


    Author: kathseem (kathy.seeman@noris.org)
  3. if you have a chance use a complete empty repository (perhaps based on a SOLID database??). Import the XML files from tree2/exports as well as tree2/data Do not forget to set in your ASN file $variation to utree after you have compiled all with ...\idf.exe /all you can give it a test (and run the debugger directly so you can see what happens) with ...\uniface.exe /deb utree right-mouseclick gives you features like new-department or new-person so you can see how it is added to the tree


    Author: ulrich-merkel (ulrichmerkel@web.de)
  4. Hi, Tree widget is not very simple. I try to retrieve data from two tables in insert that in a tree : Status OK. After, I would like to remove the content of the tree and create a new fieldvalrep from a new criterious, and all nodes exist. I have try with option -1 to remove the node, and each time, I have an issue. If you have a sample with creation of the tree in a button not in the execute, and a button to remove a node, and add a node, I will happy if you can send it to me. Regards, Antoine


    Author: apicaud (antoine.picaud@free.fr)
  5. Trees are based on list of lists.   Code the tree construction/manipulation procedure with a service that generates the new list of list. Pass to the service as params, a simple list (or id_list) with the nodes that conforms the new tree. And then something like $fieldvalrep(TREE.DUMMY) = PSO_NEWLIST   If you want to delete nodes, something like : delitem/id $fieldvalrep(TREE.DUMMY), "%%VN_ID_NODE%%%"   Regards


    Author: fearandir (fearandir@gmail.com)
  6. Hello, a tree is a bit tricky in Uniface. All relevant information is scattered around the ulibrary and it's not easy to put them all together. The big question is if you want to build the whole tree at once and to this again and again... or if you want to dynamically change the tree at runtime. The former is quite easy if you understand the valrep. The latter is very tricky and ulibrary lacks many info (AFAIK) and its much better to look at guitree samples - there are two samples: GuiTree1.zip and GuiTree2.zip. The valrep is just an idlist, where ID is ID for the node and Value is sublist like "parent_ID;node_type;Representation". The ID must be unique, of course. And don't forget that parent must be defined *before* any child - if you disorder this you won't see the nodes. Dynamically changing the tree is possible only with $fieldvalrep (not $valrep). The syntax is like this: $fieldvalrep(MYTREE.DUMMY) = "0=;%%$1" - this will update the tree, either update existing nodes and/or add new ones. $fieldvalrep(MYTREE.DUMMY) = "%%$1" - this will define a completely new tree. Another tricky thing is that you can use only one update (via $fieldvalrep) between form is shown. That is, you have to prepare all the changes and then use the $fieldvalrep() only once, or you have to use the show statement to refresh the screen and to be able to apply another one. $fieldvalrep(MYTREE.DUMMY) = "-1;$1" will remove the nodes provided. Here you provide the ID of nodes to be removed. I thing only the top-most node of subtree is necessary. $fieldvalrep(MYTREE.DUMMY) = "-2;$1" will reorder the tree... here you provide idlist with ID the main node and value is a sublist of order of id's Be warned that format of $1 is different for each mode - this is not documented well in ulibrary, but it's quite easy understandable in the GuiTree samples. I use this in a form with 2 trees where user can move nodes (even the whole subtrees) from one tree to another and vice versa. User can even reorder the whole trees. If you do all this using only one statement with a long lists provided, it seems to be quite fast enough. Good luck with trees. Zdeněk


    Author: sochaz (zdenek.socha@fullsys.cz)