D&D Behavior for Special Rows/Cells

Use

You can use this process to define a Drag & Drop behavior for special rows or cells of the grid control. Each row or cell can have its own Drag & Drop behavior.

Process

  1. Define the layout structure of type LVC_S_LAYO.

  2. Add a Drag & Drop table of type LVC_T_DRDR to your output table, as shown in the example below:

    DATA: BEGIN OF GT_OUTTAB OCCURS 0.
            INCLUDE STRUCTURE <DDIC-Struktur>.
    DATA: CT TYPE LVC_T_DRDR. "Table for d&d cell behaviour
    DATA: END OF GT_OUTTAB.
  3. Define your Drag & Drop behavior and get its handle with method get_handle of class cl_dragdrop.

  4. Select your data and copy it in the output table.

  5. Read one row of the output table at a time in a loop. A row of the Drag & Drop table has two fields. Assign values to these fields as follows (see also the graphic in the next section):

    • If the entire row should have a Drag & Drop behavior, assign the corresponding handle to field dragdropid. Field fieldname does not receive a value in this case.

    • If only specific columns of the row should have a Drag & Drop behavior, you must append one row for each column to the Drag & Drop table. Assign the name of the desired column to field fieldname, and the corresponding handle to field dragdropid.

  6. Assign the name of the internal table to field s_dragdrop-fieldname of the layout structure (in our case'CT', see step 2).

  7. Pass the layout structure and the output table with method set_table_for_first_display.

Example

The following graphic shows an output table where cells b1 and c1 have different Drag & Drop behaviors and the entire second row has the same Drag & Drop behavior as cell c1: