06-23-2017 1:15 PM
Hello experts,
i have an ALV tree and basically what i need to do is to slide (DRAG) a specific node to the top or bottom or a specific site in the ALV tree !
for example, here i wanna slide 'IF' node in place before 'AFFECATIONS' node :
=> Expected node's arrangement :
Any thoughts of how this is could be done ?
06-27-2017 2:21 PM
Please any help ?? i haven't found any soultion yet 😞
06-29-2017 7:34 PM
There are the events ON_DRAG* and ON_DROP* so it should be possible. Did you use CL_GUI_ALV_TREE or CL_GUI_ALV_TREE_SIMPLE ?
07-01-2017 12:15 PM
Heloo Sandra,
i used CL_GUI_ALV_TREE , what i m looking for just hoa to change the arrangement's nodes !!?
best regards.
Hamza CHIOUA.
07-01-2017 12:16 PM
Please any help ? i still haven't any solution for this task 😕
07-01-2017 6:38 PM
You have these 2 demo programs:
They show how to use the events mentioned above.
Here are the most important lines of code for drag & drop handling for CL_GUI_ALV_TREE, which is for single node selection only:
CLASS lcl_dndobj definiTION.
public section.
methods constructor.
endclass."
CLASS lcl_dndobj IMPLEMENTATION.
method constructor.
"...
endmethod."
endclass."
CLASS lcl_app DEFINITION.
PUBLIC SECTION.
METHODS on_drag
FOR EVENT on_drag
OF cl_gui_alv_tree
IMPORTING
DRAG_DROP_OBJECT
FIELDNAME
NODE_KEY
sender.
METHODS on_drop
FOR EVENT on_drop
OF cl_gui_alv_tree
IMPORTING
DRAG_DROP_OBJECT
NODE_KEY
sender.
ENDCLASS."
CLASS lcl_app IMPLEMENTATION.
METHOD on_drag.
" DRAG_DROP_OBJECT
" FIELDNAME
" NODE_KEY
data: ls_output type ty_gs_alv_tree.
CALL METHOD sender->get_outtab_line
EXPORTING
i_node_key = node_key
IMPORTING
e_outtab_line = ls_output
EXCEPTIONS
node_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
create object DRAG_DROP_OBJECT->object TYPE lcl_dndobj
exporting
entity_id = ls_output-entity_id.
ENDIF.
ENDMETHOD."
METHOD on_drop.
" DRAG_DROP_OBJECT
" NODE_KEY
data: lo_dndobj TYPE REF TO lcl_dndobj.
lo_dndobj ?= DRAG_DROP_OBJECT.
ENDMETHOD."
ENDCLASS."
SET HANDLER go_app->on_drag FOR go_tree.
SET HANDLER go_app->on_drop FOR go_tree2.
You may also find more information at SAP Library: Drag and Drop.