Using IlvHierarchicalSheet
The class is a subclass of IlvSheet that displays a tree structure in one of its columns. It can be considered as a special IlvTreeGadget object that handles several columns. The tree items are of the type IlvTreeGadgetItem, which means that the API used to handle a tree hierarchy is very close to the IlvTreeGadget object. See Using IlvTreeGadget.
A Hierarchical Sheet
This section covers the following topics:
Changing the Tree Hierarchy
The hierarchical sheet has an invisible root item that can be retrieved using the getRoot member function.
Changing a Hierarchy
To create a hierarchical list of items, you can do the following:
-
Create tree gadget items as explained in Creating a Hierarchy and add them one by one to the hierarchical sheet with addItem member function.
-
Create a complete new hierarchy and add it to the tree gadget in a single operation. To do so, create tree gadget items as explained above and add them as children using insertChild. This solution is more efficient than the first one.
Then you can add the root of your new hierarchy to the tree with addItem as shown below:
IlvTreeGadgetItem* item = new IlvTreeGadgetItem("New Item");
item->insertChild(new IlvTreeGadgetItem("Leaf 1"));
item->insertChild(new IlvTreeGadgetItem("Leaf2"));
hsheet->addItem(0 /* hsheet->getRoot() */, item);
Removing Items
When you add a new item to the tree gadget, its corresponding row is created automatically. Similarly, when you remove an item, its row is deleted.
Navigating through a Tree Hierarchy
Changing the Characteristic of a Tree Item
See Changing the Characteristic of an Item.
Expanding and Collapsing a Gadget Item
When an item becomes invisible because one of its parents has been collapsed, its corresponding row in the sheet disappears. Note, however, that it is not deleted.
Changing the Look of the Tree Gadget Hierarchy
The lines that link items to their parents can be displayed or hidden using the showLines member function.
You can define the indentation between an item and its parent using the setIndent member function.
Event Handling and Callbacks
The Expand Callback
The Shrink Callback
When the user collapses a tree gadget item, the Shrink callback is invoked. The callback type can be retrieved with