4D v13.4Creating and using hierarchical list boxes |
||
|
4D v13.4
Creating and using hierarchical list boxes
Creating and using hierarchical list boxes
4D v12 lets you specify and use hierarchical list boxes. A hierarchical list box is a list box in which the contents of the first column appears in hierarchical form. This type of representation is adapted to the presentation of information that includes repeated values and/or values that are hierarchically dependent (country/region/city and so on). Only aray type list boxes can be hierarchical. Hierarchical list boxes are a particular way of representing data but they do not modify the data structure (arrays). Hierarchical list boxes are managed exactly the same way as regular list boxes. To specify a hierarchical list box, there are three different possibilities:
This section covers how to create hierarchical list boxes in the 4D Form editor and the basics of how they work during execution. For more information about programmed management of hierarchical list boxes (selections, breaks, using On Expand and On Collapse form events, etc. ), refer to Managing Hierarchical List Boxes in the 4D Language Reference manual. You can enable and configure the hierarchical mode in the "Hierarchy" theme of the Property List. For more information, refer to List box specific properties. When you click on the columns area of a list box, the context menu of the Form editor contains the Create hierarchy and Cancel hierarchy commands. When you select at least one column in addition to the first one in a list box object (of the array type) in the form editor, the Create hierarchy command is available in the context menu: When you choose this command, the following actions are carried out:
Example: given a list box whose first columns contain Country, Region, City and Population. When Country, Region and City are selected (see illustration above), if you choose Create hierarchy in the context menu, a three-level hierarchy is created in the first column, columns 2 and 3 are removed and the Population column becomes the second:
When the first column is selected and already specified as hierarchical, you can use the Cancel hierarchy command. When you choose this command, the following actions are carried out:
When a form containing a hierarchical list box is opened for the first time, by default all the rows are expanded. A break row and a hierarchical "node" are automatically added in the list box when values are repeated in the arrays. For example, imagine a list box containing four arrays specifying cities, each city being characterized by its country, its region, its name and its number of inhabitants: If this list box is displayed in hierarchical form (the first three arrays being included in the hierarchy), you obtain: The arrays are not sorted before the hierarchy is constructed. If, for example, an array contains the data AAABBAACC, the hierarchy obtained is: To expand or collapse a hierarchical "node," you can just click on it. If you Alt+click (Windows) or Option+click (Mac OS) on the node, all its sub-elements will be expanded or collapsed as well. In a list box in hierarchical mode, a standard sort (carried out by clicking on the header of a list box column) is always constructed as follows:
Given for example the following list box, in which no specific sort is specified: If you click on the "Population" header to sort the populations by ascending (or alternately descending) order, the data appear as follows: As for all list boxes, you can disable the standard sort mechanism by deselecting the "Sortable" option for the list box and managing sorts using programming. When values of the date or time type are included in a hierarchical list box, they are displayed in a standard format:
|
PROPERTIES
Product: 4D |