OnLoadChildNodes - cWebTreeView
Augment this event to populate the treeview with tree items
Type: Event
Return Data Type: tWebTreeItem[]
Parameters
| Parameter | Type | Description |
|---|---|---|
| sId | String | Parent node Id |
| sValue | String | Parent node value |
| iLevel | Integer | Current node level |
Syntax
Function OnLoadChildNodes String sId String sValue Integer iLevel Returns tWebTreeItem[]
Description
By default, the cWebTreeView control does not load the entire set of tree items. Instead, it will call the Server's OnLoadChildNodes event each time it needs to display tree items that it does not currently have. For example, when the user first expands a tree item, the client will call OnLoadChildNodes and will expect that this event returns the expanded item's child nodes.
Loading the Root Tree Items
When the treeview is first loaded (i.e. the view containing the treeview is loaded on the client), the client will automatically send OnLoadChildItems with the following parameters: sID = 0, sValue = "", iLevel = 0.
Loading Child Tree Items
When a tree item is first expanded, the client will send OnLoadChildItems with the following parameters: sID = the unique item ID of the expanded item, sValue = the value associated with the expanded item, iLevel = the nesting level of the expanded item.
You should use these parameter values to identify which item was expanded and thus identify the set of child items that need to be returned.
Populating the tWebTreeItem Struct
The purpose of OnLoadChildNodes is to populate an array of tWebTreeItem structs. Each member of the array represents a tree item. The tWebTreeItem struct members describe various attributes of the tree item.
Below is a description of the tWebTreeItem struct members:
sID - This can be any string or numeric value that uniquely identifies the tree item. This must be assigned during OnLoadChildNodes. sParentID - This is the ID of the parent tree item, or 0 if it is a root item. You should set this to the sID parameter passed into OnLoadChildNodes. sName - This is the label that will be displayed in the treeview for each tree item. sAltText - This is displayed as a tooltip when the mouse is hovered over a tree item. sValue - This is an optional piece of data pertaining to the tree item. This can be used to store application specific data. sCSSClass - This is an optional CSS class that can be applied to the tree item. The CSS class should be defined somewhere in your Web Application CSS (usually in your application.css file). sIcon - This is the name of an image file that can be displayed for a tree item. If you leave this blank, then a pre-defined image will be shown. The pre-defined image is based on the current theme CSS (psTheme) and whether the item represents a folder or not. bFolder - Set this value to True or False: True indicates that the tree item represents a folder (or branch), False indicates that the tree item represents a leaf. This is used to determine which icon will be used from the current CSS theme to represent the item (assuming the sIcon member is not specified). bLoadChildren - Set this to True to indicate that the tree item can be expanded to reveal child tree items (i.e. the item is expandable). bExpanded - Do not set this member directly. This will be assigned by the framework. If True, it indicates that the tree item is currently in the expanded state.
See cWebTreeView for an example that demonstrates how to populate a treeview with tree items.
Return Value
Array of child tree nodes