Getting Started with the Column Tree Model
Use
This section lists the functions that are specific to the Column Tree Model.
Prerequisites
The process described here is an extension of the general process for using controls that is specific to the column tree model. It does not contain all of the steps required to produce a valid instance of the control.
Process
Creating the Instance
-
Define a reference variable for the column tree model:
DATA column_model TYPE REF TO cl_column_tree_model.
-
Define a work area for the hierarchy heading by referring to the structure TREEMHHDR:
DATA hierarchy_header TYPE treemhhdr.
-
Fill the work area for the hierarchy heading. You can set the width (width ), the text (heading), an icon (t_image) and a tool tip (tooltip). There are also methods that allow you to change these attributes later on.
hierarchy_header-heading = 'Title'. hierarchy_header-width = 30.
-
Create an instance of the SAP Tree Model:
CREATE OBJECT column_model EXPORTING parent = container node_selection_mode = node_selection_mode hide_selection = hide_selection item_selection = item_selection hierarchy_column_name = hierarchy_column_name hierarchy_header = hierarchy_header EXCEPTIONS illegal_node_selection_mode = 1 illegal_column_name = 2.
-
Register the Events
Register the events of the Column Tree Model. The control supports the following events:
Event Name
Description
NODE_DOUBLE_CLICK
User double-clicked a node
EXPAND_NO_CHILDREN
Node without children was expanded
SELECTION_CHANGED
The selected node has changed.
NODE_CONTEXT_MENU_REQUEST
Request of a context menu for a node
NODE_CONTEXT_MENU_SELECT
User selected an entry from the context menu
DEFAULT_CONTEXT_MENU_REQUEST
User requested a context menu with the cursor positioned on an empty space in the control
DEFAULT_CONTEXT_MENU_SELECT
User selected an entry from the context menu
HEADER_CONTEXT_MENU_REQUEST
User selected an entry from the context menu
HEADER_CONTEXT_MENU_SELECT
User selected an entry from the context menu
ITEM_KEYPRESS
User selected an entry from the context menu
NODE_KEYPRESS
User selected an entry from the context menu
HEADER_CLICK
The user clicked on a heading.
If you set the parameter item_selection = 'X'when you created the instance, you can also react to the following events:
Event Name
Description
BUTTON_CLICK
The user clicked an item with the class BUTTON
LINK_CLICK
The user clicked an item with the class LINK
CHECKBOX_CHANGE
The user clicked an item with the class CHECKBOX
ITEM_DOUBLE_CLICK
The user double-clicked an item
ITEM_CONTEXT_MENU_REQUEST
User requested a context menu with the cursor positioned on an item
ITEM_CONTEXT_MENU_SELECT
User selected an entry from the context menu for an item
-
Using the Column Tree
Add nodes to the tree. To do this, fill a node table (type TREEMCNOTA, line type TREEMCNODT), then pass it to the Column Tree Model using the method .
-
Add the items. To do this, fill an item table (type TREEMCITAC, line type TREEMCITEN), then pass it to the column tree model using method add_items.
-
Create the tree control instance that will display the data. Up until now, you have been working with the tree model on the application server. However, this cannot, of itself, display the data, so you now need to create the frontend tree. You now have to create the drontend tree. Create an SAP container control for this and copy a reference to this container to method create_tree_control.
CALL METHOD column_model->create_tree_control EXPORTING parent = container.