Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Can't change image and text of the node in CL_GUI_LIST_TREE dynamically

altaf_abap
Discoverer
0 Kudos

I have to change the node icon and node text at runtime from internal table, but not able to do, I have tried class CL_GUI_LIST_TREE with all necessary methods but can't update node image and node text. It shows only image and text which was assigned at first time tree execution.

Thanks

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

No issue for me. I duplicated SAPTLIST_TREE_CONTROL_DEMO, added the following code in method HANDLE_NODE_DOUBLE_CLICK, tested by double-clicking any node (not an item), and the new icon reflected immediately:

    CALL METHOD G_TREE->node_set_n_image
      EXPORTING
        node_key          = 'Root'
        n_image           = '@5B@'    " green light
      EXCEPTIONS
        failed            = 1
        node_not_found    = 2
        cntl_system_error = 3
        others            = 4.
    CALL METHOD G_TREE->node_set_exp_image
      EXPORTING
        node_key          = 'Root'
        exp_image         = '@5B@'
      EXCEPTIONS
        failed            = 1
        node_not_found    = 2
        cntl_system_error = 3
        others            = 4.
    CALL METHOD G_TREE->item_set_t_image
      EXPORTING
        node_key          = 'New1'
        item_name         = '1'
        t_image           = '@5B'
      EXCEPTIONS
        failed            = 1
        node_not_found    = 2
        item_not_found    = 3
        cntl_system_error = 4
        others            = 5.
2 REPLIES 2

Sandra_Rossi
Active Contributor
0 Kudos

No issue for me. I duplicated SAPTLIST_TREE_CONTROL_DEMO, added the following code in method HANDLE_NODE_DOUBLE_CLICK, tested by double-clicking any node (not an item), and the new icon reflected immediately:

    CALL METHOD G_TREE->node_set_n_image
      EXPORTING
        node_key          = 'Root'
        n_image           = '@5B@'    " green light
      EXCEPTIONS
        failed            = 1
        node_not_found    = 2
        cntl_system_error = 3
        others            = 4.
    CALL METHOD G_TREE->node_set_exp_image
      EXPORTING
        node_key          = 'Root'
        exp_image         = '@5B@'
      EXCEPTIONS
        failed            = 1
        node_not_found    = 2
        cntl_system_error = 3
        others            = 4.
    CALL METHOD G_TREE->item_set_t_image
      EXPORTING
        node_key          = 'New1'
        item_name         = '1'
        t_image           = '@5B'
      EXCEPTIONS
        failed            = 1
        node_not_found    = 2
        item_not_found    = 3
        cntl_system_error = 4
        others            = 5.

0 Kudos

Thanks,

This seems to be working fine.