Application Development and Automation 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: 
Read only

cl_salv_tree - Expand functionality not available

Former Member
0 Likes
1,614

Dear SDN members,

I am trying to use CL_SALV_TREE in a very simple way. I only want a simple tree with two columns, in which I would like to be able to navigate to subnodes etc...

The code I implemented is like this:


* Create instance
    CALL METHOD cl_salv_tree=>factory
      IMPORTING
        r_salv_tree = gr_tree
      CHANGING
        t_table     = it_produtos_cat.

* Get nodes reference
  gr_nodes = gr_tree->get_nodes( ).

*Add first node 
  gr_node = gr_nodes->add_node(
      related_node   = key       " empty at this moment
      relationship   = cl_salv_nodes=>if_salv_c_node_relation~parent
    data_row       = wa_produtos
    visible        = abap_true
  expander       = abap_true
    enabled        = abap_true
    folder         = abap_true ).

* Get Key of the node added
  key = gr_node->get_key( ).

*Add first child 
  gr_node = gr_nodes->add_node(
      related_node   = key       " key from the first node
      relationship   = cl_salv_nodes=>if_salv_c_node_relation~last_child
    data_row       = wa_produtos
    visible        = abap_true
  expander       = abap_true
    enabled        = abap_true
    folder         = abap_false ).

* display tree
  gr_tree->display( ).

At the moment I have two problems, the major problem is that I do not have a expander icon to expand the first node...actually in this version of my code I can only see the first node. I am quite sure the relation is ok, because when I you the method


* Expand all nodes
  gr_nodes->expand_all( ).

before display, all nodes apear. But all without expander icon and consequently it is not possible to expand or collapse the nodes.

The other problem is that when I select one or more nodes, and execute method


* Get selected nodes
gr_selections = gr_tree->get_selections( ).
lt_nodes = gr_selections->get_selected_nodes( ).

The nodes table lt_nodes is always empty!!!

Any ideas?! Specially for my first problem (Expander is not available) ?

Thanks for any help.

Regards

MPM

P.S.: I tried already the method SET_EXPANDER of class cl_salv_node.

Edited by: Marcelo Moreira on Nov 11, 2009 4:41 PM

Dear SDN members,

I am trying to use CL_SALV_TREE in a very simple way. I only want a simple tree with two columns, in which I would like to be able to navigate to subnodes etc...

The code I implemented is like this:


* Create instance
    CALL METHOD cl_salv_tree=>factory
      IMPORTING
        r_salv_tree = gr_tree
      CHANGING
        t_table     = it_produtos_cat.

* Get nodes reference
  gr_nodes = gr_tree->get_nodes( ).

*Add first node 
  gr_node = gr_nodes->add_node(
      related_node   = key       " empty at this moment
      relationship   = cl_salv_nodes=>if_salv_c_node_relation~parent
    data_row       = wa_produtos
    visible        = abap_true
  expander       = abap_true
    enabled        = abap_true
    folder         = abap_true ).

* Get Key of the node added
  key = gr_node->get_key( ).

*Add first child 
  gr_node = gr_nodes->add_node(
      related_node   = key       " key from the first node
      relationship   = cl_salv_nodes=>if_salv_c_node_relation~last_child
    data_row       = wa_produtos
    visible        = abap_true
  expander       = abap_true
    enabled        = abap_true
    folder         = abap_false ).

* display tree
  gr_tree->display( ).

At the moment I have two problems, the major problem is that I do not have a expander icon to expand the first node...actually in this version of my code I can only see the first node. I am quite sure the relation is ok, because when I you the method


* Expand all nodes
  gr_nodes->expand_all( ).

before display, all nodes apear. But all without expander icon and consequently it is not possible to expand or collapse the nodes.

The other problem is that when I select one or more nodes, and execute method


* Get selected nodes
gr_selections = gr_tree->get_selections( ).
lt_nodes = gr_selections->get_selected_nodes( ).

The nodes table lt_nodes is always empty!!!

Any ideas?! Specially for my first problem (Expander is not available) ?

Thanks for any help.

Regards

MPM

P.S.: I tried already the method SET_EXPANDER of class cl_salv_node.

Edited by: Marcelo Moreira on Nov 11, 2009 4:41 PM

1 REPLY 1
Read only

Former Member
0 Likes
759

Dear SDN Members,

The code I presented before actually is ok....but there are 2 lines missing. They seem to be not really important, but they make the diference.

The two lines missing are:


gr_columns = gr_tree->get_columns( ).
gr_columns->set_optimize( abap_true ).

These two likes make the expander icon appear....if you do not have these two lines, no expander is shown!!

Now, I still have the problem of the selected nodes method.

Any ideas for the final problem?

Thanks!