Technology Blog Posts by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
cahit_guerguec
Advisor
Advisor
18,771


One of the most powerful interaction design pattern available to developers is Drag-and-Drop.

Drag-and-Drop allows moving, reordering and applying actions to objects. This makes it a simple and intuitive action, in line with Fiori and users’ expectations.

With SAPUI5 version 1.56, a new dragAndDrop aggregation with multiplicity 0..n is now available for every Control in UI5 and it can be used to configure complete drag-and-drop scenarios via DragInfoDropInfo or DragDropInfo without really giving it much thought!

Let's briefly have a look at this simple but powerful drag-and-drop condiguration objects.

 



 

DragInfo can be used just to allow dragging when drop target is not known or not owned. Additional draggable checks can be done at the dragStart event and default can be prevented.

DropInfo can be used as a general drop target. Incoming data may need to be validated at the dragEnter event. Applications should just implement the drop event.

DragDropInfo can be used when the drag source and the drop target are tightly coupled and both are known. The most common use-case is enablement own aggregations.

Both DragInfo and DropInfo offers groupName property. If this property is specified, then the DropInfo object will only interact with the relevant DragInfo objects within the same group.

Let's don't make this attractive topic boring with long texts. Let's see a little code snippet first.










 Enable reordering of the items inside the List
 <List items="{/Products}">
    <dragDropConfig>
        <dnd:DragDropInfo
            sourceAggregation="items"
            targetAggregation="items"
            dropPosition="Between"
            drop="onReorderItems"/>
    </dragDropConfig>
 </List>


 

Now let's see Drag-and-Drop in action.

 

If you could follow all the links above that means you've learned already a lot. Now it is time for fun! ? Yes... UI5 is not only for enterprise-ready web applications, sometimes just for jun. Let's play a little drag-and-drop game and don't hesitate to hack the source code if you cannot solve the puzzle.



 

Here are some useful links if you want to know more about drag-and-drop in UI5.

 

Previous post: UI5ers Buzz #31



Cahit







"Guess who I am?".charAt.call(Number, 1) + (this + "")[9] + [...[...'.....']].length + ``.substr.call(/(?:)/.constructor.name, 3) + alert.name.slice(-3);


 



17 Comments