Using the Column Tree

Use

This section lists the functions that are specific to the column tree.

Prerequisites

The process described here is an extension of the general process for using controls that is specific to the simple tree. It does not contain all of the steps required to produce a valid instance of the control.

Process

Creating the Instance

  1. Define a reference variable for the column tree:

    DATA column_tree TYPE REF TO cl_gui_column_tree. 
  2. Define a work area for the hierarchy heading by referring to the structure treev_hhdr:

    DATA hierarchy_header TYPE treev_hhdr.
  3. Fill the work area for the hierarchy heading. You can set the width (width and width_pix), 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.
  4. Create an instance of the tree control:

    
    CREATE OBJECT column_tree
     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
      lifetime_error                = 1
      cntl_system_error                  = 2
      create_error                  = 3 
      illegal_node_selection_mode   = 4
      failed                        = 5
      illegal_column_name           = 6.

Register the Events

Register events for the column tree. 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

  1. Add nodes to the tree. First fill a node table and a table with the entries and copy this with the add_nodes_and_items method:

    
    CALL METHOD column_tree->add_nodes_and_items
     EXPORTING
      node_table                    = node_table
      item_table                    = item_table
      item_table_structure_name     = item_table_structure_name
    
     EXCEPTIONS
      failed                           = 1
      cntl_system_error                = 2
      error_in_tables                  = 3
      dp_error                         = 4
      table_structure_name_not_found   = 5.
  2. Change existing nodes in the tree, or change the tree attributes (see Changing the Attribtues of the Control).

  3. Query any necessary attributes of the tree and its nodes (see Finding Out the Attributes of the Control).

Destroying the Control

  • Destroy the custom control at the frontend. If you do not need the control container any more, destroy it as well:

    CALL METHOD column_tree->free.
  • Delete the reference variables to the simple tress and the control container, if required.

    FREE column_tree.