06-12-2015 3:35 PM
Hi,
I have alv tree, where checkbox is in first column. If checkbox is pressed all of the nodes with are childrens are selected.
Two first main nodes are expanded when program starts.
The problem is, that I can't expand others nodes after start of program. (example in picture, I'm sure, that there are some items in that catalog)
When I press checkbox, the items are selected and node is expanded and after that I can collapse and expand node, before that, it's impossible.
Code in class handling event checkbox:
METHOD handle_checkbox.
DATA:
lt_nodes_to_sel TYPE lvc_t_nkey,
lt_selected_nodes TYPE lvc_t_nkey
.
FIELD-SYMBOLS:
<ls_node> LIKE LINE OF lt_nodes_to_sel
.
CALL METHOD lo_alv_tree->get_subtree
EXPORTING
i_node_key = node_key
IMPORTING
et_subtree_nodes = lt_nodes_to_sel.
IF checked = 'X'.
APPEND LINES OF lt_nodes_to_sel to mt_selected_nodes.
CALL METHOD lo_alv_tree->set_selected_nodes
EXPORTING
it_selected_nodes = mt_selected_nodes
* EXCEPTIONS
* cntl_system_error = 1
* dp_error = 2
* failed = 3
* error_in_node_key_table = 4
* others = 5
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
loop at lt_nodes_to_sel ASSIGNING <ls_node>.
DELETE mt_selected_nodes WHERE TABLE_LINE = <ls_node>.
endloop.
CALL METHOD lo_alv_tree->unselect_nodes
EXPORTING
it_node_key = lt_nodes_to_sel
* EXCEPTIONS
* cntl_system_error = 1
* dp_error = 2
* multiple_node_selection_only = 3
* error_in_node_key_table = 4
* failed = 5
* others = 6
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMETHOD.
Code in programi, with may be reason:
APPEND INITIAL LINE TO lt_events ASSIGNING <ls_event>.
<ls_event>-eventid = cl_gui_column_tree=>eventid_checkbox_change.
CALL METHOD go_alv_tree->set_registered_events
EXPORTING
events = lt_events
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
illegal_event_combination = 3.
IF sy-subrc <> 0.
* MESSAGE x208(00) WITH 'ERROR'. "#EC NOTEXT
ENDIF.
06-12-2015 4:53 PM
Hello Adam,
You have to add the event "cl_gui_column_tree=>eventid_expand_no_children". to lt_events.
Regards,
Venkat.
06-12-2015 4:53 PM
Hello Adam,
You have to add the event "cl_gui_column_tree=>eventid_expand_no_children". to lt_events.
Regards,
Venkat.
06-12-2015 4:59 PM
Thanks!
It works, but why I have to do that? There are childrends for each node.
06-12-2015 5:11 PM
Hello Adam,
I am not an expert on this, but my guess is that , the Column tree model does a lazy loading; I think instead of loading all the nodes onto the GUI, it loads them as requested, first loading the parent only.
Hence, you would have to treat this as an event where a server round trip is needed to load the child nodes. In this case the Std SAP method handles the event.
Again, I assume this to be reasoning .
Regards,
Venkat.