Tree Nodes

When the parent and child nodes come from different tables or are of different data types, the parent/child relationship is not automatically set up. In this case, the runtime engine does not automatically fetch the child database records because it does not know the table from which to retrieve them.

If possible, use the runtime engine to load the initial set of parent nodes to the tree for you. You do this by using the based-on view, which is a view over the table for the uppermost node. You can use a parent filter in the control, and the runtime engine loads the first level nodes to the tree. If you cannot do this, you must insert the first-level nodes yourself. To do this, you typically use table I/O on the Button is Clicked event of the Find button. You use the same methods that you use to insert child nodes. Use a Suppress Find system function to stop the runtime engine from attempting to load any nodes.

Whenever a node is expanded, the system function, Suppress Fetch on Node Expand, is called from the event, Tree Node Is Expanded. This function tells the runtime engine not to do any fetches because ER will handle the loading of the child nodes. Tree Node Is Expanding is the main event of the application. This event occurs when the tree node is expanding (such as when the plus next to a child node is expanded for the first time). You place ER on this event to read the next records to be loaded to the tree as children of the expanded node. You can use table I/O or business functions to retrieve these records. Often the children come from different tables, based on the type of parent node that is expanded. If possible, you should perform a SELECT and then use the FETCH NEXT command to retrieve records in a DO WHILE loop. The grid buffer (GB) runtime data structure is populated with data from the records read in the loop, and then an Insert Grid Buffer Row system function is called. This parent/child system function is different from the Insert Grid Buffer Row in the normal grid section. At this point, you also can set custom tree bitmaps using the Set Tree Node Bitmap system function.