Getting Started with the List Tree Model

Use

This section lists the functions that are specific to the list tree model.

Prerequisites

The process described here is an extension of the general process for using controls that is specific to the list 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 list tree model:

    DATA list_model TYPE REF TO cl_list_tree_model.
  2. If you want to create a heading for the tree, you must create a work area for the hierarchy heading with reference to the structure TREEMHHDR and one for the list heading with reference to the structure TREEMLHDR:

    DATA hierarchy_header TYPE treemhhdr.
    DATA list_header type treemlhdr.
  3. 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.
  4. Fill the work area for the hierarchy heading. You can set the text (heading), an icon (t_image) and a tool tip (tooltip).

    list_header-heading = 'List heading'.
  5. Create an instance of the SAP list tree model:

    CREATE OBJECT list_model
     EXPORTING
      node_selection_mode     = node_selection_mode
      hide_selection          = hide_selection
      item_selection          = item_selection
      with_headers            = with_headers
      hierarchy_header        = hierarchy_header
      list_header             = list_header
    
     EXCEPTIONS
      illegal_node_selection_mode   = 1.
  6. Register the Events

    Register the events for the list 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

  7. Using the List Tree

    Create a node table (type TREEMLNOTA, line type TREEMLNODT), and fill it with the nodes that you want to want to add to the list tree model. Then pass the table with method add_nodes to the tree model instance:

    CALL METHOD list_model->add_nodes
            EXPORTING node_table = node_table.
  8. Create a node table (type TREEMLITAC, line type TREEMLITEN), and fill it with the nodes that you want to want to add to the list tree model. Then pass the table with method add_items to the tree model instance.

    CALL METHOD list_model->add_items
            EXPORTING item_table = item_table.
  9. 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 front-end 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.