cancel
Showing results for 
Search instead for 
Did you mean: 

Enabling Drag and Drop on specific Rows of a (Tree)Table.

MaxiHogger
Discoverer
0 Kudos

I wonder how one can enable Drag and Drop only for certain rows of a TreeTable.

I am aware that i can just enable it for all rows and then determine if the Drag and Drop Target is valid in the respective Events. But this way the user still sees the Drag and Drop cursor for all the rows even though he cant actually Drag them. 

Initially i thought i can use the RowSettingsTemplate and use a Binding together with a formatter to enable or disable the Drag and Drop for each of the automatically generated rows. So something like this here:

<table:rowSettingsTemplate>
    <table:RowSettings>
        <table:dragDropConfig>
            <dnd:DragInfo
            enabled="{ parts: [{path: 'NodeType'}],formatter:'.formatter.setDragAndDropEnabled' }"
            dragStart="onDragStart"
            />
            <dnd:DropInfo
            enabled="{ parts: [{path: 'NodeType'}], formatter:'.formatter.setDragAndDropEnabled' }"
            dropPosition="OnOrBetween"
            drop="onDrop"/>
        </table:dragDropConfig>
    </table:RowSettings>
</table:rowSettingsTemplate>

What would be the right way to enable drag and drop only for certain rows? 

Thanks in advance!

 

Accepted Solutions (1)

Accepted Solutions (1)

Edrilan_Berisha
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Maxi,

 

in the library documentation: https://sapui5.hana.ondemand.com/sdk/#/topic/81e3f38f5e3e4194bb32675c86b49ba2

It's mentioned that 

"When you use drag and drop, the following restrictions apply:

  • [...]
  • Defining constraints for the drag position is not possible.

  • [...]"

 

To be honest I wonder what kind of use case you have, that you do not want to display it on certain rows. Shouldn't you rather follow the approach to display an error, when the user tries to drag and drop something, which in your table, where you have a business reason to not allow it?

Otherwise the user would believe there could be a potential bug involved in here, on some rows it is enabled and on some it isn't.

 

 

Best,

Edrilan Berisha

SAP S/4HANA Cloud Financials Development

MaxiHogger
Discoverer
0 Kudos
Hi Edrilan, thanks for your quick reply. I had actually read about the position restriction. I must admit that I wasn't exactly sure what it meant. The restriction to only move certain rows in the table is due to the fact that users should be able to reposition individual documents (i.e. the last nesting level in the TreeTable) but not entire folders (nodes with sub-nodes). Now that I know that it is not possible to restrict the position, it is probably best to display an error. Even if I'm not quite so happy about the fact that the drag cursor is then displayed for the majority of the table although, as I said, you can and should only actually move a fraction of it. Best regards Maxi

Answers (0)