Drag&Drop in ALV Grid
Hello everybody,
I would like to use D&D to insert a line into ALVGrid. I have defined a Tree as source ALV Grid as target and added a onDrag and onDrop Listeners for views. When the ALV table have lines yet the cursor show that drop is possible and onDrop method is called. But, when ALV is empty I can't drop line to ALV The same occurred, when I have first added lines with '+' or 'NEW' button. What should I do to can drop in empty Table??
Regards
Bogdan
Hi,
Check this Report. BCALV_GRID_DND_TREE_SIMPLE
it uses following method.
create object dragdrop_tree.
call method dragdrop_tree->add exporting
flavor = 'LINE'
dragsrc = selected
droptarget = ''
effect = g_dropeffect.
call method dragdrop_tree->get_handle importing
handle = g_handle_tree.
-> ALV grid
create object dragdrop_alv.
call method dragdrop_alv->add exporting
flavor = 'LINE'
dragsrc = ''
droptarget = selected
effect = g_dropeffect.
call method dragdrop_alv->get_handle importing
handle = g_handle_alv.
Regards,
Amit
Reward all helpful replies.
Similar Messages
-
How i can do a drag drop between container (grid)?
I am trying to work out a task with Drag and Drop(WPF ,C#)to include in a demo ,i will explain easy showing an example of code in XAML
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="container1" Grid.Row="0" >
<Grid Name="grid1" Background="Aqua" Margin="15"></Grid>
</Grid>
<Grid x:Name="container2" Grid.Row="1" >
<Grid Name="grid2" Background="blue" Margin="15"></Grid>
</Grid>
<Grid x:Name="container3" Grid.Row="2" >
<Grid Name="grid3" Background="green" Margin="15"></Grid>
</Grid>
</Grid>
My purpose is when the user drag the
grid1 in the
container2 automatically the grid2 will go to place in the
container1 (basically I want to swap the grids) then this process will be used every time need to drag a grid in a container. with a code that i wrote down i can do a simple drag&drop i can drag the "grid1"
to the "container2" but cannot send back automatically the grid2 to container1.
Kindly i ask if you have any advise or tips to make successful this task.
Thank you so much for your attention
Cheers!!!
*********EDIT*********
Using this code as follow i can do the drag&drop but what really i need is the grid "container "is fix and never move just the
"grid" should move between the "container "
<StackPanel Name="sp" AllowDrop="True" Background="SkyBlue" PreviewMouseLeftButtonDown="sp_PreviewMouseLeftButtonDown" PreviewMouseLeftButtonUp="sp_PreviewMouseLeftButtonUp" PreviewMouseMove="sp_PreviewMouseMove"
DragEnter="sp_DragEnter" Drop="sp_Drop">
<Grid Name="grid1" Background="Aqua" Height="120" Width="500"></Grid>
<Grid Name="grid2" Background="Blue" Height="120" Width="500"></Grid>
<Grid Name="grid3" Background="Red" Height="120" Width="500"></Grid>
</StackPanel>
private bool _isDown;
private bool _isDragging;
private Point _startPoint;
private UIElement _realDragSource;
private UIElement _dummyDragSource = new UIElement();
public MainWindow()
InitializeComponent();
private void sp_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
if (e.Source == this.sp)
else
_isDown = true;
_startPoint = e.GetPosition(this.sp);
private void sp_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
_isDown = false;
_isDragging = false;
_realDragSource.ReleaseMouseCapture();
private void sp_PreviewMouseMove(object sender, MouseEventArgs e)
if (_isDown)
if ((_isDragging == false) && ((Math.Abs(e.GetPosition(this.sp).X - _startPoint.X) > SystemParameters.MinimumHorizontalDragDistance) ||
(Math.Abs(e.GetPosition(this.sp).Y - _startPoint.Y) > SystemParameters.MinimumVerticalDragDistance)))
_isDragging = true;
_realDragSource = e.Source as UIElement;
_realDragSource.CaptureMouse();
DragDrop.DoDragDrop(_dummyDragSource, new DataObject("UIElement", e.Source, true), DragDropEffects.Move);
private void sp_DragEnter(object sender, DragEventArgs e)
if (e.Data.GetDataPresent("UIElement"))
e.Effects = DragDropEffects.Move;
private void sp_Drop(object sender, DragEventArgs e)
if (e.Data.GetDataPresent("UIElement"))
UIElement droptarget = e.Source as UIElement;
int droptargetIndex=-1, i =0;
foreach (UIElement element in this.sp.Children)
if (element.Equals(droptarget))
droptargetIndex = i;
break;
i++;
if (droptargetIndex != -1)
this.sp.Children.Remove(_realDragSource);
this.sp.Children.Insert(droptargetIndex, _realDragSource);
_isDown = false;
_isDragging = false;
_realDragSource.ReleaseMouseCapture();
Thanks :)Hello Jonny,
Currently I do not have a sample and I have reviewed this post and find another way which seems more reasonable. Have you cosidered use a ListView instead of common grid. It seems we can do what you want with two common grid however we need to hardcoded
all the things.
If we use ListView, for example, you can see this thread:
http://stackoverflow.com/questions/20573063/creating-icon-view-mode-for-listview-wpf
and this thread:
http://stackoverflow.com/questions/9443695/how-do-i-drag-drop-items-in-the-same-listview
We can drag and drop items instead of grid, which will make this programming much easier than hard code to switch your control's location.
Best regards,
Barry
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Dear Barry Wang thank you so much for your kind support ,just open me a way to do it ,you can see in this post https://social.msdn.microsoft.com/Forums/vstudio/en-US/55873851-e86c-4a20-9b00-de3419054ba8/get-stuck-to-dragdrop-in-this-case?forum=wpf .
Wish you a Happy New Year .
Sincerley -
Can't drag & drop thumbnails in grid view
Version 1.2: While in Grid view, I am unable to drag and drop thumbnails to manually sort. I am grabbing from the center of the thumbnail and the thumbnail turns to the dotted rectangle. However, when I drag, nothing happens.
Has anybody encountered this?
Thank you.Shut off include photos from subitems.
This exact question was answered yesterday. -
MULTIPLE-ROW drag and drop between 2 ALV grids
Hi,
Can anybody help me with acheiving MULTIPLE-ROW drag and drop functionality between 2 ALV grids.hi Prakash,
Actually I'm trying to develop multiple drag and drop between 2 ALV's. To understand the events properly, I started working on this sample program where it uses 1 ALV and splits it into 2 and uses single row drag and drop between them. Now I'm making it to work for multiple drag and drop, so that I can use it on my application. This is the code which I'm working on..
*& Report Z_ALV_GRID_CONTROLS_DRAG_DROP *
REPORT z_alv_grid_controls_drag_drop.
DATA : i_ztransactions TYPE TABLE OF ztransactions
WITH HEADER LINE.
DATA : i_ztransactions2 TYPE TABLE OF ztransactions
WITH HEADER LINE.
DATA : ok_code LIKE sy-ucomm .
DATA : mcontainer TYPE REF TO cl_gui_custom_container .
DATA : mcontleft TYPE REF TO cl_gui_container .
DATA : mcontright TYPE REF TO cl_gui_container .
DATA : msplitcont TYPE REF TO
cl_gui_easy_splitter_container .
DATA : malv_left TYPE REF TO cl_gui_alv_grid .
DATA : malv_right TYPE REF TO cl_gui_alv_grid .
DATA : mrow TYPE lvc_s_row .
DATA : gt_outtab_source TYPE ztransactions.
DATA : gt_outtab_target TYPE ztransactions.
DATA : g_repid LIKE sy-repid.
DATA: gs_layout TYPE lvc_s_layo ,
g_behaviour_alv TYPE REF TO cl_dragdrop .
DATA : mlines TYPE i .
CLASS lcl_dragdropobj DEFINITION
This is the Class of Drag Drop Object .
This Object is used as a temporary storage means
of the information extracted with drag
CLASS lcl_dragdropobj DEFINITION.
PUBLIC SECTION.
DATA: i_ztransactions TYPE ztransactions ,
index TYPE i ,
original_table(5) TYPE c ,
proceed_trans(1) TYPE c .
ENDCLASS. "lcl_dragdropobj DEFINITION
DATA : mdata TYPE REF TO lcl_dragdropobj .
CLASS DND_TOOLS DEFINITION
This class contains the methods responding to the
events ONDRAG , ONDROP , ONDROPCOMPLETE
of the ALV Grid Controls
CLASS dnd_tools DEFINITION .
PUBLIC SECTION .
METHODS:handle_user_command
FOR EVENT user_command OF
cl_gui_alv_grid
IMPORTING
e_ucomm.
METHODS : handle_drag_from_left
FOR EVENT ondrag OF
cl_gui_alv_grid
IMPORTING
e_row
e_dragdropobj .
METHODS : handle_dropcomplete_from_left
FOR EVENT ondropcomplete OF
cl_gui_alv_grid
IMPORTING
e_row
e_dragdropobj .
METHODS : handle_drag_from_right
FOR EVENT ondrag OF
cl_gui_alv_grid
IMPORTING
e_row
e_dragdropobj .
METHODS : handle_dropcomplete_from_right
FOR EVENT ondropcomplete OF
cl_gui_alv_grid
IMPORTING
e_row
e_dragdropobj .
METHODS : handle_drop_to_left
FOR EVENT ondrop OF
cl_gui_alv_grid
IMPORTING
e_dragdropobj .
METHODS : handle_drop_to_right
FOR EVENT ondrop OF
cl_gui_alv_grid
IMPORTING
e_dragdropobj .
ENDCLASS . "DND_TOOLS DEFINITION
CLASS DND_TOOLS IMPLEMENTATION
CLASS dnd_tools IMPLEMENTATION .
METHOD handle_drag_from_left .
METHOD handle_user_command.
DATA: lt_rows TYPE lvc_t_row.
DATA: lt_rows TYPE lvc_t_roid.
DATA: lt_row TYPE lvc_s_roid.
DATA: mdata TYPE REF TO lcl_dragdropobj .
DATA: dragdropobj TYPE REF TO lcl_dragdropobj .
get selected row
CALL METHOD malv_left->get_selected_rows
IMPORTING
et_row_no = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.
CREATE OBJECT mdata.
LOOP AT lt_rows INTO lt_row.
mrow = lt_row .
READ TABLE i_ztransactions INDEX lt_row-row_id INTO
i_ztransactions.
MOVE i_ztransactions TO mdata->i_ztransactions .
MOVE lt_row-row_id TO mdata->index.
MOVE 'LEFT' TO mdata->original_table .
e_dragdropobj->object = mdata .
ENDLOOP.
ENDMETHOD. "handle_user_command
METHOD handle_dropcomplete_from_left .
NB : the following data object MDATA is local to
the method and contains the information from the
import parameter of the method E_DRAGDROPOBJ
DATA : mdata TYPE REF TO lcl_dragdropobj .
DATA: lt_rows TYPE lvc_t_roid.
DATA: lt_row TYPE lvc_s_roid.
CALL METHOD malv_left->get_selected_rows
IMPORTING
et_row_no = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.
LOOP AT lt_rows INTO lt_row.
mdata ?= e_dragdropobj->object .
CHECK mdata->proceed_trans = 'X' .
mrow = mdata->index.
DELETE i_ztransactions INDEX mrow .
APPEND mdata->i_ztransactions TO i_ztransactions2 .
SORT i_ztransactions2 BY kunnr belnr .
DELETE i_ztransactions2 WHERE kunnr IS INITIAL .
DESCRIBE TABLE i_ztransactions LINES mlines .
IF mlines EQ 0 .
CLEAR i_ztransactions .
APPEND i_ztransactions TO i_ztransactions .
ENDIF .
ENDLOOP.
CALL METHOD malv_left->refresh_table_display.
CALL METHOD malv_right->refresh_table_display.
ENDMETHOD . "HANDLE_DROPCOMPLETE_FROM_LEFT
METHOD handle_drag_from_right.
mrow = e_row-index .
READ TABLE i_ztransactions2 INDEX mrow INTO
i_ztransactions2 .
CREATE OBJECT mdata .
MOVE i_ztransactions2 TO mdata->i_ztransactions .
MOVE mrow TO mdata->index .
MOVE 'RIGHT' TO mdata->original_table .
e_dragdropobj->object = mdata .
ENDMETHOD . "HANDLE_DRAG_FROM_RIGHT
METHOD handle_dropcomplete_from_right .
DATA : mdata TYPE REF TO lcl_dragdropobj .
mdata ?= e_dragdropobj->object .
CHECK mdata->proceed_trans = 'X' .
mrow = mdata->index .
DELETE i_ztransactions2 INDEX mrow .
APPEND mdata->i_ztransactions TO i_ztransactions .
SORT i_ztransactions BY kunnr belnr .
DELETE i_ztransactions WHERE kunnr IS INITIAL .
DESCRIBE TABLE i_ztransactions2 LINES mlines .
IF mlines EQ 0 .
CLEAR i_ztransactions2 .
APPEND i_ztransactions2 TO i_ztransactions2 .
ENDIF .
CALL METHOD malv_left->refresh_table_display.
CALL METHOD malv_right->refresh_table_display.
ENDMETHOD . "HANDLE_DROPCOMPLETE_FROM_RIGHT
METHOD handle_drop_to_left .
DATA : mdata TYPE REF TO lcl_dragdropobj .
mdata ?= e_dragdropobj->object .
IF mdata->original_table = 'RIGHT' .
mdata->proceed_trans = 'X' .
ELSE .
mdata->proceed_trans = ' ' .
ENDIF .
e_dragdropobj->object = mdata .
ENDMETHOD . "HANDLE_DROP_TO_LEFT
METHOD handle_drop_to_right .
DATA : mdata TYPE REF TO lcl_dragdropobj .
DATA: lt_rows TYPE lvc_t_roid.
DATA: lt_row TYPE lvc_s_roid.
CALL METHOD malv_left->get_selected_rows
IMPORTING
et_row_no = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.
LOOP AT lt_rows INTO lt_row.
mdata ?= e_dragdropobj->object .
IF mdata->original_table = 'LEFT' .
mdata->proceed_trans = 'X' .
ELSE .
mdata->proceed_trans = ' ' .
ENDIF .
e_dragdropobj->object = mdata .
ENDLOOP.
ENDMETHOD . "HANDLE_DROP_TO_RIGHT
ENDCLASS . "DND_TOOLS IMPLEMENTATION
DATA : mlistener TYPE REF TO dnd_tools .
======================================================
START OF SELECTION
======================================================
START-OF-SELECTION .
PERFORM get_data .
CALL SCREEN 100 .
The screen 100 has the custom control MCONTAINER and
on the flow logic has the following modules :
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE PREPARE_SCREEN .
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
(Off course not commented out in the real flow logic)
FORM GET_DATA *
FOR THIS EXAMPLE THE DATA SELECTION IS HARD CODED
FORM get_data .
CLEAR : i_ztransactions , i_ztransactions[] .
i_ztransactions-mandt = sy-mandt .
i_ztransactions-waers = 'EUR ' .
i_ztransactions-kunnr = '0000000001' .
i_ztransactions-belnr = '0000000001' .
i_ztransactions-bldat = '20030101' .
i_ztransactions-dmbtr = '1000' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000002' .
i_ztransactions-bldat = '20030202' .
i_ztransactions-dmbtr = '1010' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000003' .
i_ztransactions-bldat = '20030323' .
i_ztransactions-dmbtr = '1020' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000004' .
i_ztransactions-bldat = '20030404' .
i_ztransactions-dmbtr = '1030' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000005' .
i_ztransactions-bldat = '20030505' .
i_ztransactions-dmbtr = '1040' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000006' .
i_ztransactions-bldat = '20030606' .
i_ztransactions-dmbtr = '1050' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000007' .
i_ztransactions-bldat = '20030707' .
i_ztransactions-dmbtr = '1060' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000008' .
i_ztransactions-bldat = '20030808' .
i_ztransactions-dmbtr = '1070' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000009' .
i_ztransactions-bldat = '20030909' .
i_ztransactions-dmbtr = '1080' .
APPEND i_ztransactions .
i_ztransactions-belnr = '0000000010' .
i_ztransactions-bldat = '20031010' .
i_ztransactions-dmbtr = '1090' .
APPEND i_ztransactions .
CLEAR : i_ztransactions2 , i_ztransactions2[] .
APPEND i_ztransactions2 .
ENDFORM . "GET_DATA
*& Module STATUS_0100 OUTPUT
The PF STATUS STATUS100 called from the module below,
has on the Standard toolbar the buttons
BACK , EXIT and CANCEL .
These buttons are provided with function code = 'EXIT'
MODULE status_0100 OUTPUT.
SET TITLEBAR 'TITLEDRAGDROP' .
SET PF-STATUS 'STATUS100'.
ENDMODULE. " STATUS_0100 OUTPUT
Module USER_COMMAND_0100 INPUT
The following module checks the User Command and ends
the program
MODULE user_command_0100 INPUT.
IF ok_code = 'EXIT' .
CLEAR : mcontainer ,
mcontleft ,
mcontright ,
msplitcont ,
malv_left ,
malv_right .
LEAVE TO SCREEN 0 .
ENDIF .
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module PREPARE_SCREEN OUTPUT
MODULE prepare_screen OUTPUT.
IF mcontainer IS INITIAL .
CREATE OBJECT mcontainer
EXPORTING
container_name = 'MCONTAINER' .
CREATE OBJECT msplitcont
EXPORTING
parent = mcontainer
orientation = 1 .
mcontleft = msplitcont->top_left_container .
mcontright = msplitcont->bottom_right_container .
CREATE OBJECT malv_left
EXPORTING i_parent = mcontleft .
gs_layout-sel_mode = 'D'.
CREATE OBJECT malv_right
EXPORTING i_parent = mcontright .
gs_layout-sel_mode = 'D'.
PERFORM set_layout_capable_of_drag_dro
USING 'X' 'X' .
CALL METHOD malv_left->set_table_for_first_display
EXPORTING
i_structure_name = 'ZTRANSACTIONS'
is_layout = gs_layout
CHANGING
it_outtab = i_ztransactions[].
CALL METHOD malv_right->set_table_for_first_display
EXPORTING
i_structure_name = 'ZTRANSACTIONS'
is_layout = gs_layout
CHANGING
it_outtab = i_ztransactions2[].
CREATE OBJECT mlistener .
CALL METHOD malv_left->set_toolbar_interactive.
SET HANDLER mlistener->handle_drag_from_left
FOR malv_left .
SET HANDLER mlistener->handle_dropcomplete_from_left
FOR malv_left .
SET HANDLER mlistener->handle_drag_from_right
FOR malv_right.
SET HANDLER mlistener->handle_dropcomplete_from_right
FOR malv_right .
SET HANDLER mlistener->handle_drop_to_right
FOR malv_right .
SET HANDLER mlistener->handle_drop_to_left
FOR malv_left .
ENDIF .
ENDMODULE. " PREPARE_SCREEN OUTPUT
Form SET_LAYOUT_CAPABLE_OF_DRAG_DRO
Definition of a Drag & Drop behaviour for the ALV
grid
FORM set_layout_capable_of_drag_dro USING drag drop.
DATA : effect TYPE i ,
handle_alv TYPE i .
CREATE OBJECT g_behaviour_alv.
effect = cl_dragdrop=>move + cl_dragdrop=>copy .
CALL METHOD g_behaviour_alv->add
EXPORTING
flavor = 'Line'
dragsrc = drag
droptarget = drop
effect = effect.
CALL METHOD g_behaviour_alv->get_handle
IMPORTING
handle = handle_alv.
gs_layout-s_dragdrop-row_ddid = handle_alv.
ENDFORM. " SET_LAYOUT_CAPABLE_OF_DRAG_DRO -
ALV Grid Drag & Drop - Cell-specific
Hi ABAPers,
I've referred SAP Standard program / SDN forum and got some logic for ALV Drag & Drop for row-specific, Column-specific and for Trees. But I didn't get for Cell-specific.
My requirement is :
If the user drags a particular cell to another cell in an ALV-grid, then that Cell value should be copied to the 'Dropped-Cell' in the ALV Grid and should be saved to that particular Internal Table.I have referred the SAP standard program BCALV_DND_03 which does from a different tree to a cell. My requirement is from the same ALV grid Table.
I've also referred BCALV_DND_04 which is useful. But here, it does it for the whole row.
Can anyone please help me in this?
Thanks a lot.
Best Regards,
SowmyaTOP INCLUDE:
DATA: BEGIN OF g_t_plan_alv_m OCCURS 0,
header,
count(5).
INCLUDE STRUCTURE g_ze6spw_plan_alv.
DATA: handle_style TYPE lvc_t_styl,
handle_dragdrop TYPE lvc_t_drdr,
tabcolor TYPE lvc_t_scol.
DATA: END OF g_t_plan_alv_m.
CLASS cl_gui_resources DEFINITION LOAD.
CLASS lcl_events_dragdrop DEFINITION DEFERRED.
DATA:
BEGIN OF g_ty_s_outtab OCCURS 0,
header,
count(5).
INCLUDE STRUCTURE g_ze6spw_plan_alv.
DATA: handle_style TYPE lvc_t_styl,
handle_dragdrop TYPE lvc_t_drdr,
tabcolor TYPE lvc_t_scol,
END OF g_ty_s_outtab.
DATA: g_field TYPE lvc_fname.
DATA:
gr_events TYPE REF TO lcl_events_dragdrop,
gr_dragdrop TYPE REF TO cl_dragdrop,
gr_dragdrop_background TYPE REF TO cl_dragdrop.
CLASS lcl_events_dragdrop DEFINITION.
PUBLIC SECTION.
DATA: m_grid TYPE i.
METHODS:
ondrag FOR EVENT ondrag
OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no
e_dragdropobj,
ondrop FOR EVENT ondrop
OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no
e_dragdropobj,
ondropcomplete FOR EVENT ondropcomplete
OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no
e_dragdropobj,
ondropgetflavor FOR EVENT ondropgetflavor
OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no
e_dragdropobj
e_flavors.
ENDCLASS. "LCL_DRAGDROP DEFINITION
* CLASS lcl_dragdrop_obj DEFINITION
CLASS lcl_dragdrop_obj DEFINITION.
PUBLIC SECTION.
DATA: line LIKE g_ty_s_outtab,
index TYPE i.
ENDCLASS. "lcl_dragdrop_obj DEFINITION
CLASS lcl_events_dragdrop IMPLEMENTATION.
METHOD ondrag.
PERFORM event_ondrag USING e_row
e_column
e_dragdropobj.
ENDMETHOD. "ondrag
METHOD ondrop.
PERFORM event_ondrop USING e_row
e_column
e_dragdropobj.
ENDMETHOD. "ondrop
METHOD ondropcomplete.
PERFORM event_ondropcomplete USING e_row
e_column
e_dragdropobj.
ENDMETHOD. "ondropcomplete
METHOD ondropgetflavor.
PERFORM event_ondropgetflavor USING e_row
e_column
es_row_no
e_dragdropobj
e_flavors.
ENDMETHOD. "ondropgetflavor
ENDCLASS. "LCL_objdragdropapp IMPLEMENTATION
FORM set_drag_drop.
DATA: l_effect TYPE i,
l_dragdrop_handle TYPE i,
ls_dragdrop TYPE lvc_s_dd01,
ls_drag_cell TYPE lvc_s_drdr,
lt_drag_cells TYPE lvc_t_drdr,
ls_fcat TYPE lvc_s_fcat,
l_field TYPE lvc_fname,
l_source TYPE char1,
l_target TYPE char1,
l_alv_exclude_tab TYPE ui_functions,
l_variant TYPE disvariant.
FIELD-SYMBOLS: <fs_brcp> TYPE zreceipt,
<fs_bisu> TYPE z_supply.
CREATE OBJECT gr_dragdrop.
CREATE OBJECT gr_dragdrop_background.
CREATE OBJECT gr_events.
SET HANDLER gr_events->ondrag
FOR g_plan_alv.
SET HANDLER gr_events->ondrop
FOR g_plan_alv.
SET HANDLER gr_events->ondropcomplete
FOR g_plan_alv.
SET HANDLER gr_events->ondropgetflavor
FOR g_plan_alv.
LOOP AT g_t_plan_alv_m.
MOVE-CORRESPONDING g_t_plan_alv_m TO g_ty_s_outtab.
APPEND g_ty_s_outtab.
ENDLOOP.
l_effect = cl_dragdrop=>move + cl_dragdrop=>copy.
CALL METHOD gr_dragdrop->add
EXPORTING
flavor = 'Line' "#EC NOTEXT
dragsrc = c_on
droptarget = c_on
effect = l_effect.
CALL METHOD gr_dragdrop->get_handle
IMPORTING
handle = l_dragdrop_handle.
ls_dragdrop-cntr_ddid = l_dragdrop_handle. "auch bei leerem Grid
ls_dragdrop-grid_ddid = space.
ls_dragdrop-col_ddid = space.
ls_dragdrop-row_ddid = space.
ls_dragdrop-fieldname = 'HANDLE_DRAGDROP'.
g_plan_layo-s_dragdrop = ls_dragdrop.
LOOP AT g_t_mat_index.
*Bulk Issues
CONCATENATE c_plan_alvm c_bisu g_t_mat_index-index INTO l_field.
ASSIGN (l_field) TO <fs_bisu>.
CLEAR l_field.
*Bulk Receipts
CONCATENATE c_plan_alvm c_brcp g_t_mat_index-index INTO l_field.
ASSIGN (l_field) TO <fs_brcp>.
CLEAR l_field.
ls_drag_cell-fieldname = <fs_brcp>."l_field.
ls_drag_cell-dragdropid = l_dragdrop_handle.
INSERT ls_drag_cell INTO TABLE lt_drag_cells.
CLEAR ls_drag_cell.
ls_drag_cell-fieldname = <fs_bisu>."l_field. 9th May
ls_drag_cell-dragdropid = l_dragdrop_handle.
INSERT ls_drag_cell INTO TABLE lt_drag_cells.
CLEAR ls_drag_cell.
ENDLOOP.
DATA: l_index TYPE i,
l_erg TYPE i.
LOOP AT g_t_plan_alv_m.
l_index = sy-tabix.
l_erg = sy-tabix MOD 2.
IF l_erg EQ 0.
g_t_plan_alv_m-handle_dragdrop = lt_drag_cells.
g_t_plan_alv_m-tabcolor = lt_tabcolor.
MODIFY g_t_plan_alv_m INDEX l_index "FROM ls_outtab
TRANSPORTING handle_dragdrop
tabcolor.
ENDIF.
ENDLOOP.
LOOP AT g_t_plan_alv_m.
l_index = sy-tabix.
l_erg = sy-tabix MOD 2.
IF l_erg EQ 0.
g_t_plan_alv_m-handle_dragdrop = lt_drag_cells.
g_t_plan_alv_m-tabcolor = lt_tabcolor.
MODIFY g_t_plan_alv_m INDEX l_index "FROM ls_outtab
TRANSPORTING handle_dragdrop
tabcolor.
ENDIF.
ENDLOOP.
CALL METHOD g_plan_alv->set_table_for_first_display
EXPORTING
is_variant = l_variant
i_save = g_save
is_layout = g_plan_layo
it_toolbar_excluding = l_alv_exclude_tab[]
CHANGING
it_outtab = g_t_plan_alv_m[]"gt_outtab_source[]
it_fieldcatalog = g_t_plan_fcat[].
ENDFORM. " DRAGDROP
FORM event_ondrag USING e_row TYPE lvc_s_row
e_column TYPE lvc_s_col
e_dragdropobj TYPE REF TO
cl_dragdropobject. "#EC
DATA:
l_obj TYPE REF TO lcl_dragdrop_obj.
CREATE OBJECT l_obj.
READ TABLE g_t_plan_alv_m INDEX e_row-index. "9thMay
IF sy-subrc EQ 0.
l_obj->line = g_t_plan_alv_m."ls_outtab.
l_obj->index = e_row-index.
e_dragdropobj->object = l_obj.
ENDIF.
ENDFORM. " EVENT_ONDRAG
FORM event_ondrop USING e_row TYPE lvc_s_row
e_column TYPE lvc_s_col
e_dragdropobj TYPE REF TO
cl_dragdropobject. "#EC
DATA: l_obj TYPE REF TO lcl_dragdrop_obj,
ls_outtab LIKE g_ty_s_outtab.
CREATE OBJECT l_obj.
IF e_row-index IS INITIAL.
e_row-index = 1.
ENDIF.
CATCH SYSTEM-EXCEPTIONS move_cast_error = 1.
l_obj ?= e_dragdropobj->object.
ls_outtab = l_obj->line.
MODIFY g_t_plan_alv_m INDEX e_row-index.
ENDCATCH.
IF sy-subrc <> 0.
CALL METHOD e_dragdropobj->abort.
ENDIF.
ENDFORM. " EVENT_ONDROP
*& Form EVENT_ONDROPCOMPLETE
* -->P_E_ROW text
* -->P_E_COLUMN text
* -->P_E_DRAGDROPOBJ text
FORM event_ondropcomplete USING e_row type lvc_s_row
e_column type lvc_s_col
e_dragdropobj type ref to
cl_dragdropobject."#EC
data: l_obj type ref to lcl_dragdrop_obj,
ls_stable type lvc_s_stbl,
lr_grid type ref to cl_gui_alv_grid.
ls_stable-row = c_on."con_true.
ls_stable-col = c_on."con_true.
catch system-exceptions move_cast_error = 1.
l_obj ?= e_dragdropobj->object.
endcatch.
lr_grid ?= e_dragdropobj->droptargetctrl.
call method lr_grid->refresh_table_display
exporting
is_stable = ls_stable.
ENDFORM. " EVENT_ONDROPCOMPLETE
*& Form EVENT_ONDROPGETFLAVOR
* -->P_E_ROW text
* -->P_E_COLUMN text
* -->P_ES_ROW_NO text
* -->P_E_DRAGDROPOBJ text
* -->P_E_FLAVORS text
FORM event_ondropgetflavor USING p_e_row
p_e_column
p_es_row_no
p_e_dragdropobj
p_e_flavors.
ENDFORM. " EVENT_ONDROPGETFLAVOR -
I have a report which has 2 ALV grids side by side. I am able to drag a cell from the left grid and drop it in the right grid. But I also want to drag a cell from the right grid to another cell in the right grid. I can't seem to make this work. Does anyone have any suggestions here?
Thanks,
JackHi Jack,
Did you define the drag-and-drop behaviour correctly for both grids? Perhaps you can copy the piece of coding where you define the D&D behaviour, so we can have a look at it.
Kind regards,
John. -
Hi everyone,
is it possible to do drag & drop between 2 ALV (Grid/Tree)? Could some one provide me with a example coding please?
Thanks for your help in advance.check this demo program
BCALV_TEST_GRID_DRAG_DROP
Raja -
Drag & Drop ALV row to a picture control
Hello. I'm trying to implement drag&drop functionality from an ALV grid to a picture/icon(CL_GUI_PICTURE). Anyone know if this is possible. I can't get my events to fire when dragging/dropping. I have been able to do it from ALV to ALV, but am getting stuck on ALV to Picture. I want some kind of "shopping cart" functionality like in ME22N, where the user can drag a PO from a list into the "shopping cart" picture/icon.
Anyone can help?
Regards,
Rich HeilmanGood afternoon!
I'm trying to do the same, to drag a node of a tree and drop it on a picture control. I have called the set_dragdrop_control and set_dragdrop_picture methods and I'm sure of the set handler statement, but no event is fired.
Can you help me?
Thank you,
Fabiano (from Brazil). -
Popup instead of list when using WD4A ALV Grid Drop Down By Key
I am develop a WD4A application and I am using an ALV grid. I have set the cell editor for one column wiht the following code:
CREATE OBJECT lr_ddbk
EXPORTING
SELECTED_KEY_FIELDNAME = 'ZCURRENCY'.
Data: lv_key_visable TYPE abap_bool,
lv_key_visible_fieldname TYPE string.
lr_ddbk->set_type( if_salv_wd_c_uie_drdn_by_index=>type_key_value ).
* lv_key_visable = lr_ddbk->GET_KEY_VISIBLE( ).
* lv_key_visible_fieldname = lr_ddbk->GET_KEY_VISIBLE_FIELDNAME( ).
* lr_ddbk->SET_KEY_VISIBLE( abap_false ).
lr_alv_column->SET_CELL_EDITOR( lr_ddbk ).
This code works fine. I then fill the drop down with the following code:
*...Build the currency drop down list
DATA lv_default_currency TYPE wdr_context_attr_value.
DATA lv_currency_count TYPE STRING.
DATA ls_tcurt TYPE tcurt.
CLEAR ls_contextvalue_set.
CLEAR lt_contextvalue_set. REFRESH lt_contextvalue_set.
CLEAR lv_default_currency.
loop at it_ac_attr into ls_ac_attr.
if ls_ac_attr-attr_id eq 'CUR'.
select single * from tcurt into ls_tcurt
Where spras = 'EN' AND
waers = ls_ac_attr-value.
If sy-subrc = 0.
ls_contextvalue_set-value = ls_ac_attr-value.
ls_contextvalue_set-value = ls_ac_attr-value.
ls_contextvalue_set-text = ls_tcurt-ktext.
IF ls_ac_attr-DFT_FLAG = 'X'.
lv_default_currency = ls_contextvalue_set.
ENDIF.
append ls_contextvalue_set to lt_contextvalue_set.
endif.
Endif.
endloop.
lo_nd_zebuy_describe_item_info = lo_nd_zebuy_describe_item->get_node_info( ).
lo_nd_zebuy_describe_item_info->set_attribute_value_set(
exporting
name = 'ZCURRENCY'
value_set = lt_contextvalue_set ).
*...End build currency drop down list
This code works fine. The issue I am having is that the drop down is behaving like a search help field rather than a drop down list. Meaning a popup comes when I drop down the list. The popup has the values I have set. I don't want a popup I want a drop down list. Additionallly the field is editable (meaning I can type a value into the field as well as select a value). I want the user to only be able to select values from the list. Any help with this issue would be appreciated.I fugured out what I was doing wrong. I was setting the cell editor to cl_salv_wd_uie_input_field later in the code by mistake.
-
Dear Expert,
I am new to OOPS ,
I want to display drop down list for a particular field in my output, so I am using OOPS but in my below code
I am facing problem in displaying the output as I am getting the error message
Field catalog not found...
Also advice me how to display drop down list in a particular field.
Please advice
MODULE pbo OUTPUT.
SET PF-STATUS 'ZTEST'.
IF g_custom_container IS INITIAL.
DATA: lt_exclude TYPE ui_functions,
lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
CREATE OBJECT g_grid
EXPORTING
i_parent = g_custom_container.
PERFORM field_catalog TABLES it_lvc_t_fcat
USING: 'S_FINAL' 'MATNR' ' ' 'Part Number' ' ' ' ',
'S_FINAL' 'MAKTX' ' ' 'Part Description' ' ' ' ',
'S_FINAL' 'MBLNR' ' ' 'Document No' ' ' ' ',
'S_FINAL' 'BLDAT' ' ' 'Document date' ' ' ' ',
'S_FINAL' 'LIFNR' ' ' 'Vendor Number' ' ' ' ',
'S_FINAL' 'STATUS' ' ' 'Acknowledgement' ' ' 'X',
'S_FINAL' 'REMARKS' ' ' 'Remarks' ' ' 'X'.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
* I_STRUCTURE_NAME =
is_layout = it_lvc_s_layo
CHANGING
it_outtab = i_final
it_fieldcatalog = it_lvc_t_fcat
ENDIF.
ENDMODULE. " PBO OUTPUT
FORM field_catalog TABLES t_field_catalog STRUCTURE wt_lvc_s_fcat
USING fp_tabname TYPE any
fp_fieldname TYPE any
fp_key TYPE any
fp_text TYPE any
fp_do_sum TYPE any
fp_edit TYPE any.
t_field_catalog-tabname = fp_tabname.
t_field_catalog-fieldname = fp_fieldname.
t_field_catalog-key = fp_key.
t_field_catalog-seltext = fp_text.
t_field_catalog-do_sum = fp_do_sum .
t_field_catalog-edit = fp_edit .
ENDFORM. "field_catalog
Edited by: Karthik R on Mar 15, 2010 6:11 PMHi Karthik,
Below mentioned is a Simple code for creating dropdown lists for columns in ALV grid output
REPORT z_alv_dropdown.
*Type pools declarations for ALV
TYPE-POOLS : slis.
*data declarations for ALV container, ALV grid, Field catalogues & layout
DATA: g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo.
*INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
wa_outtab TYPE t517a.
*initialisation event
INITIALIZATION.
*Start of selection event
START-OF-SELECTION.
*Call to ALV
CALL SCREEN 600.
*On this statement double click it takes you to the screen painter SE51.
*Create a Custom container and name it CCONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.
PBO of the actual screen , Here we can give a title and customized menus
Here we also call the subroutine for ALV output.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
set pf-status 'xxx'.
set titlebar 'MAIN100'.
Subroutine to display the output in alv
PERFORM alv_output.
ENDMODULE. "pbo OUTPUT
PAI module of the screen created. In case we use an interactive ALV or
*for additional functionalities we can create OK codes and
based on the user command we can do the coding.
MODULE PAI INPUT *
MODULE pai INPUT.
ENDMODULE. "pai INPUT
*& Form BUILD_FIELDCAT
FORM build_fieldcat.
DATA ls_fcat TYPE lvc_s_fcat.
*Build the field catalogue
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'T517A'
CHANGING
ct_fieldcat = gt_fieldcat.
To assign dropdown in the fieldcataogue
LOOP AT gt_fieldcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'SLART'.
*drdn-hndl = '1' is the first list box
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
*drdn-hndl = '2' is the second list box
WHEN 'ABART'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
ENDCASE.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form ALV_OUTPUT
FORM alv_output .
*Create object for container
CREATE OBJECT g_custom_container
EXPORTING container_name = 'CCONT'.
*create object for grid
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
Build fieldcat and set column
*Assign a handle for the dropdown listbox.
PERFORM build_fieldcat.
*Build layout
PERFORM build_layout.
Define a drop down table.
PERFORM dropdown_table.
*fetch values from the T517A table
SELECT * FROM t517a INTO TABLE gt_outtab.
*Display ALV output
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab.
ENDFORM. "ALV_OUTPUT
*& Form dropdown_table
text
--> p1 text
<-- p2 text
FORM dropdown_table.
*Declarations for drop down lists in ALV.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
First SLART listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = '01 Pink'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '02 Yellow'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '03 Green'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '04 Black'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '05 White'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '06 Blue'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '09 Other Colors'.
APPEND ls_dropdown TO lt_dropdown.
*method to display the dropdown in ALV
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.
ENDFORM. " dropdown_table
*& Form build_layout
text
*layout for ALV output
FORM build_layout .
gs_layout-cwidth_opt = 'X'.
gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
gs_layout-no_toolbar = 'X'.
ENDFORM. " build_layout
Hope it is helpful,
Regards,
Soundarya. -
ALV Grid display Drop down lists
I have a alv grid display with a few records say 5 records which display 5 columns 5 rows. I want to know is it possible to have drop down lists for each column row cell but with different drop down values for each record.
So 5 columns 5 rows 25 cells but each cell have different drop down values.
Any info would be appreciatedHi,
Thanks for the replies.
Currently i do understand how to get the drop down handle per column and add values but this will only show the drop down values for each cell the same for each column.
What i am trying is that each cell of each colum of each row must have different drop down values.
Example below: Where the ; is devider for new value as a drop down value for that cell
Record-- column1---column2 column3 column4 column5
1 -
a;b;c -
d;e;f -
g;h;i -
k;l;m -
o;i
2 -
l;k;j -
i;j;g----
q;e;r -
o;u;g -
g;d;e -
Drag And Drop in ALV Column Tree
Hello All,
Can anyone tell me the method used for a drag and drop in a column tree....
i found it for a simple tree but not for a column tree.....
thanks in advance....
Regards,
PraveenCheck the links -
drag drop required for alv column!
drag and drop in a tree
Drag&Drop within the Tree
Drag&Drop within a tree
Drag and drop in ALV tree
Regards,
Amit
Reward all helpful replies. -
Drag & Drop, ALV or Table Control to Tree Control
Hi Experts,
If i want Drag & Drop feature in ALV or Table Control to Tree ControlHi,
refer to the link below:
http://help.sap.com/saphelp_46c/helpdata/fr/22/a3f5fbd2fe11d2b467006094192fe3/content.htm
With luck,
Pritam. -
Unable to drag drop from grid to tree
Hi,
I am ablel to drag but unable to drop to a grid.
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" creationComplete="initVars()">
<!--STEP 2 WRITE ACTION SCRIPT to populate data and perform action-->
<mx:Script>
<![CDATA[
import mx.events.DropdownEvent;
import mx.events.DragEvent;
import mx.collections.XMLListCollection;
import mx.controls.List;
import mx.events.DataGridEvent;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]public var selectedcareplan: XMLList;
[Bindable]public var selectedBCXML: XMLListCollection;
[Bindable]public var businesscentertype: String;
[Bindable]public var selectedBCPerformers: XMLList;
[Bindable]public var selectedPerformerDetail: XMLList;
[Bindable]public var originator: String;
[Bindable]public var service: String;
[Bindable]public var performer:String;
[Bindable]public var dataFeedxml:XML;
[Bindable]var careplans:XML ;
[Bindable]var selectedplanproblem:String;
[Bindable]var selectedplanname: String;
[Bindable]var selectedplanid:String;
[Bindable]var selectedplanresult: String;
[Bindable]var selectedplansummary:String;
[Bindable]var selectedplancomments:String;
var xmltemplate: String = '';
<!--STEP 3 write a function to populate data-->
private function initVars():void
careplans = <careplanlist>
<careplan id = '1' name = 'plan name 1' result = 'Good Health' comments = 'Good' summary = 'Here isthe a summary'>
<issue>
this is a problem
</issue>
<steps>
<step id ='11' action = 'action1' output = 'out' outcome = 'outcome1'/>
<step id ='12' action = 'action2' output = 'out' outcome = 'outcome2'/>
<step id ='13' action = 'action3' output = 'out' outcome = 'outcome3'/>
<step id ='14' action = 'action4' output = 'out' outcome = 'outcome4'/>
</steps>
</careplan>
<careplan id = '2' name = 'plan name 2' result = 'Good Health2' comments = 'Good' summary = 'Here isthe a summary'>
<issue>
this is a problem
</issue>
<steps>
<step id ='21' action = 'action21' output = 'out21' outcome = 'outcome21'/>
<step id ='22' action = 'action22' output = 'out22' outcome = 'outcome22'/>
<step id ='23' action = 'action23' output = 'out23' outcome = 'outcome23'/>
<step id ='24' action = 'action24' output = 'out24' outcome = 'outcome24'/>
</steps>
</careplan>
</careplanlist>;
//selectedBCXML = new XMLListCollection(selectedcareplan);
//tree1.dataProvider = selectedBCXML;
//Alert.show("Init Variables: Care plans = " + careplans, "Alert Box", Alert.OK);
private function ViewCarePlanDetail(event: Event):void
var careplanid: String;
careplanid = XML(DataGrid(event.currentTarget).selectedItem).@id;
// Alert.show("ViewCarePlanDetail = " + careplans, "Selected Care Plan", Alert.OK);
selectedcareplan= careplans.careplan.(@id ==careplanid);
Alert.show("ViewCarePlanDetail = " + selectedcareplan, "Selected Care Plan", Alert.OK);
//selectedBCXML = new XMLListCollection(selectedcareplan);
selectedplanname = selectedcareplan.@name;
selectedplanproblem = selectedcareplan.issue;
selectedplanid = selectedcareplan.@id
selectedplanresult = selectedcareplan.@result
selectedplansummary = selectedcareplan.@summary
selectedplancomments = selectedcareplan.@comments
Alert.show("ViewCarePlanDetail = " + selectedplanname, "Selected Plan name", Alert.OK);
private function dragDropComplete(event: DragEvent):void
selectedBCXML = new XMLListCollection(selectedcareplan);
//tree1.dataProvider = selectedBCXML;
private function treeLabel(item:Object):String
var node:XML = XML(item);
if( node.localName() == "issue" )
{return "Medical Issue: "+node.toString();}
if( node.localName() == "careplan" )
return "careplan: " +node.@name;
if( node.localName() == "steps") return "steps:";
if (node.localName()=="step") return "[ step : " + node.@id +" action: " + node.@action + " output: " + node.@output + " outcome: " + node.@outcome +" ]";
return null;
]]>
</mx:Script>
<!-- STEP 1- Create data grid with columns and tree view-->
<!-- to fill data grid columns with data, you need to bring in a DATA PROVIDER to provide data to columns-->
<mx:VBox width="100%" height="100%" paddingTop="0">
<mx:Canvas width="100%" height="100%" horizontalScrollPolicy="off"
verticalScrollPolicy="off" cornerRadius="14" backgroundAlpha="0.28" backgroundColor="#C6ACAC" borderStyle="solid" borderColor="#EBF1F5" alpha="1.0">
<!--<mx:TextInput x="11" y="22" width="252" editable="false" text="{selectedBC}" color="#800000" borderStyle="inset" cornerRadius="20" fontSize="11" fontFamily="Arial" fontWeight="bold"/> -->
<!--dataProvider ="{careplans.careplan}"-->
<mx:DataGrid id = "bcs" x="10" y="83" height="96" width="663"
fontFamily="Arial" fontSize="11" color="#352525" itemClick="ViewCarePlanDetail(event);"
editable="false" enabled="true" fontWeight="bold" cornerRadius="10" dragEnabled="true"
dataProvider ="{careplans.careplan}" >
<mx:columns>
<mx:DataGridColumn headerText="Plan Name" dataField= "@id"/>
<mx:DataGridColumn headerText="Plan Id" dataField="@name"/>
<mx:DataGridColumn headerText="Result" dataField="@result"/>
<mx:DataGridColumn headerText="Comments" dataField="@comments"/>
<mx:DataGridColumn headerText="Summary" dataField="@summary"/>
</mx:columns>
</mx:DataGrid>
<mx:Label x="10" y="55" text="Available care plans" width="240" fontSize="11" fontFamily="Arial" fontWeight="bold" color="#7D4343"/>
<!--dataProvider="{selectedBCXML}"-->
<mx:Tree id="tree1" labelFunction="treeLabel" showRoot="true" width="761" height="132" x="10" y="348"
alpha="0.87" borderThickness="2" fontFamily="Arial" fontSize="11" color="#121213" cornerRadius="6"
fontWeight="bold" enabled="true" dropEnabled="true" dragDrop="dragDropComplete(event);"
dataProvider="{selectedBCXML}"/>
<mx:Label x="10" y="300" text="Selected Plan Details" width="192" fontSize="12" fontFamily="Arial" fontWeight="bold" color="#090808"/>
<mx:Label x="10" y="196" text="Care plan name" width="95"/>
<mx:Text x="115" y="196" width="135" text="{selectedplanname}" />
<mx:Label x="283" y="196" text="Problem/Issue" width="77"/>
<mx:Text x="400" y="196" width="140" text="{selectedplanproblem}"/>
<mx:Label x="10" y="222" text="Plan ID"/>
<mx:Text x="115" y="222" width="135" text="{selectedplanid}" />
<mx:Label x="283" y="235" text="Result"/>
<mx:Text x="349" y="235" width="135" text="{selectedplanresult}" />
<mx:Label x="10" y="258" text="Comments"/>
<mx:Text x="100" y="258" width="150" text="{selectedplancomments}" />
<mx:Label x="283" y="276" text="Summary"/>
<mx:Text x="349" y="276" width="148" text="{selectedplansummary}" />
</mx:Canvas>
</mx:VBox>
</mx:Canvas>
<!-- end of STEP 1-->
Help?Can anyone shed somelight into this problem please.
-
ALV Grid and a Drop-Down column
Hi All,
Currently I'm working on a Web Dynpro ABAP component where I'm display several columns of data within an ALV Grid.
I have made two of the columns input fields so the User can update the back-end tables. I want to made these two columns not only input fields, but I want them to have "Drop Down" capability (Value and Text) so that the User can pick only standard values.
Does anyone have any sample code I could use.
Thank you in Advance.
PaulHi Paul,
I dont think that you can provide the capability of both the input field & dropdown to the same columns. (Coz using input fields you should be able to enter any value you wish whereas using a dropdown you can enter a value from within the value set specified.) If you want to create a dropdown within your ALV columns then just go through the code snippet below:
I have a context node by name NODE with the attributes from SFLIGHT. I have 2 additional attributes TEMP & TEMP_NEW under the same node. I have typed them with my custom data element so that they can use the value range defined at the domain level. My task is to display these 2 columns TEMP & TEMP_NEW as dropdowns with the permissible values coming from their associated domains.
Regards,
Uday
METHOD build_alv .
DATA:
lr_alv_usage TYPE REF TO if_wd_component_usage,
lr_if_controller TYPE REF TO iwci_salv_wd_table,
lr_config TYPE REF TO cl_salv_wd_config_table,
lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lt_columns TYPE salv_wd_t_column_ref,
lr_link TYPE REF TO cl_salv_wd_uie_link_to_action,
lr_checkbox TYPE REF TO cl_salv_wd_uie_checkbox,
lr_image TYPE REF TO cl_salv_wd_uie_image,
lr_dropdown TYPE REF TO CL_SALV_WD_UIE_DROPDOWN_BY_KEY.
FIELD-SYMBOLS
<fs_column> LIKE LINE OF lt_columns.
Instantiate the ALV Component
lr_alv_usage = wd_this->wd_cpuse_alv( ).
IF lr_alv_usage->has_active_component( ) IS INITIAL.
lr_alv_usage->create_component( ).
ENDIF.
Get reference to model
lr_if_controller = wd_this->wd_cpifc_alv( ).
lr_config = lr_if_controller->get_model( ).
To get the dropdowns displayed you need to set the table to editable by using below statement
lr_config->if_salv_wd_table_settings~set_read_only( abap_false ).
Set the UI elements.
lr_column_settings ?= lr_config.
lt_columns = lr_column_settings->get_columns( ).
You can use the below commented approach to fill the dropdowns instead of using a custom domain
data: lr_node_info type ref to if_wd_context_node_info,
lr_node type ref to if_wd_context_node,
wa_value_set type wdr_context_attr_value,
lt_value_set type table of wdr_context_attr_value.
lr_node = wd_context->get_child_node( name = 'NODE' ).
lr_node_info = lr_node->get_node_info( ).
wa_value_set-value = '1'.
wa_value_set-text = 'One'.
insert wa_value_set into table lt_value_set.
wa_value_set-value = '2'.
wa_value_set-text = 'Two'.
insert wa_value_set into table lt_value_set.
wa_value_set-value = '3'.
wa_value_set-text = 'Three'.
insert wa_value_set into table lt_value_set.
lr_node_info->set_attribute_value_set( name = 'TEMP'
value_set = lt_value_set ).
LOOP AT lt_columns ASSIGNING <fs_column>.
IF <fs_column>-id = 'CARRID'.
CREATE OBJECT lr_link.
lr_link->set_text_fieldname( <fs_column>-id ).
<fs_column>-r_column->set_cell_editor( lr_link ).
ENDIF.
IF <fs_column>-id = 'TEMP'.
CREATE OBJECT lr_dropdown
EXPORTING
selected_key_fieldname = 'TEMP'.
<fs_column>-r_column->set_cell_editor( lr_dropdown ).
ENDIF.
IF <fs_column>-id = 'TEMP_NEW'.
CREATE OBJECT lr_dropdown
EXPORTING
selected_key_fieldname = 'TEMP_NEW'.
<fs_column>-r_column->set_cell_editor( lr_dropdown ).
ENDIF.
ENDLOOP.
ENDMETHOD.
Maybe you are looking for
-
Tips needed for multiple iPods and users with one PC...
We are a family of four, with four iPods and one PC. We have two (Windows) user accounts set up. My husband and son share one, and my daughter and I use the other. My husband's and son's music does not show up in my user library and visa-versa. There
-
How can i convert items of vbap into horizontal in internal table ?
Hi, Experts, I want to display items of vbap into horizontal instead of vertical using a 'reuse_alv_grid_display' fm ex: vbeln posnr netwr waerk 5680 10 120 dol 5680 20
-
My husband bought me a new Iphone today, but first backed up the old Iphone to Icloud. How do I download the old stuff. Have not been able to follow on-line directions. It's very frustrating. Give me my OLD PHONE BACK!!!
-
How do i completely remove headers from email messages
Hi everyone. Can someone tell me how to completely remove the headers from showing up in messages i send, forward or receive? I know how to make the headers shorter, but that's not what i want to do. I want to completely remove them from all outgoing
-
Hi, How can we output easily a message to the console when running a function?