This exercise is designed to show how to create a display file capable of drag and drop.
- Open the Profound UI Visual Designer, start with a new display file and name the record format SFLCTL1.
- Add an empty panel labeled Drag and Drop.
- Add an exit button labeled "Exit" bound to an indicator named BTNEXIT.
- Add two single column subfiles with output fields as shown below.
- Set the id of the first subfile to Grid1 and the second subfile to Grid2
- Set the record format name of the first subfile (Grid1) to SFLA and the second subfile (Grid2) to SFLB.
- Add an output field to each subfile bound to FIELDA and FIELDB respectively. These fields are 20A.
- Bind an indicator named SFLCLR to the "clear subfile" property of both subfiles. (The same indicator can be used with both subfiles.)
- For both subfiles, set the properties as shown:
- Select the SFTCTL1 record format and bind the following fields to the properties shown:
- Save the display file as DRAGD and compile it to your library.
Compile the code below into your QRPGLESRC. A file is attached here to import into your library: DRAGR.RPGLE
The important piece of code is shown below.
Using the data taken from DragFromId and DragToId, we can determine the subfile that the item was taken from, and where it was dropped. Then using the RemoveItem() and InsertItem() sub procedures included in the code, we can then remove the item from the original subfile and insert it into the correct position on the new subfile.
This property determines if the element can be drag and dropped.
Possible Values: True, False
This property determinse if a drag and drop proxy is created. If set to true, instead of dragging the element around, a proxy element is created and moved instead.
Possible Values: True, False
Initiates a client-side script when the user first starts to drag the element. Information about the drag and drop operation is provided using the global pui.dragDropInfo object.
Specifies a list of target id's, which identify where this element can be dropped.
Possible Values: Comma separated list of element id's
Initiates a client-side script when the user drags an element over a validdrop target during a drag operation. Information about the drag and drop operation is provided using the global pui.dragDropInfo object.
Initiates aclient-side script when the user moves an element out of a valid drop target during a drag operation. Invormatio about the drag and drop operation is provided using the global pui.dragDropInfo object.
Initiates a client-side script when the mouse is released during a drag and drop operation. Information aobut the drag and drop operation is provided using the global pui.dragDropInfo object.
pui.dragDropInfo is a global object containing information about the drag/drop operation. This object is available on the following events, , , and .
You can retrieve data from the global object by placing a property value within the object. The object contains a number of properties, but the most useful are listed below.
dd element id - This property returns the element id of the selected subfile record.
dd record number - Returns the relative record number of the selected element to drag/drop.
target element id - This returns the target element id of the where the selection is to be dropped.
target record number - This returns the relative record number of where the selection is after it has been dropped.
Custom CSS Style
As of Profound UI version 5.1.2, the style of the drop target line can be set using custom CSS. By default a dashed, gray line appears when you drag a grid item over a valid drop target:
You can change the default style by adding a CSS rule into a custom style sheet under the profoundui/userdata/custom/css/ folder (where profoundui is the installation folder). This rule makes the drop target line red:
The width of the line is 2 pixels, and the line color is #CCCCCC by default. If the grid's border width property is set, then the border width overrides any custom CSS:
If the grid's border color property is set, then the border color overrides any custom CSS: