[Drag-n-drop Sortable List] Where to Update the Table or is it even necessary?

Forge Component
(26)
Published on 2018-10-23 by Armando Gomes
26 votes
Published on 2018-10-23 by Armando Gomes

Hello,


We managed to hook Sortable to the table we want to drag around and it works visually. However upon refreshing, the table is not updated according to the order that was rearranged via dragging around. I tried to update the table using he update method that was provided but it still doesn't update the table's order. Can anyone provide input as to what we are missing? We also attached a screen action of how we use the Sortable module.


Thank You,

Yosua

Hi Yosua,

If you could share the .oml or .oap it would be easier to help you.

Regards,

Daniel

Hello Daniel,


Thank you for your reply. Attached is a simplified version of the OML.



Yosua

Hi Yosua,

In the SortableHandler action used as event handler to the VarChanged event of the Sortable web block, you did not implement the logic to persist the sort order. For an example of how to handle the sort order you can download this demo application:

https://www.outsystems.com/forge/component-overview/4598/drag-n-drop-sortable-list-demo

Then check out the login in Sortables_TR screen OnNotify action.

Regards,

Daniel

Hello Daniel,


I was under the impression that Sortable's RefreshSortable server action, that I got from importing Sortable as a dependency, would include calling the onNotify screen action. Does this mean what I am missing is a onNotify screen action of my own to make the change persist?



Best Regards,


Yosua

Your action is called SortableHandler and it is lacking the logic to save the new order on the records (the string_split and the for-each with the related logic).

If you inspect the code of RefreshSortable server action you will see that all it does is calling this javascript, 

SanitizeHtml("$('#" + Id + If(IsTableRecord, " tbody", "") + "').sortable(""refreshPositions"");")

the action is agnostic and doesn't (and can not) know anything about your entity. That logic you have to code yourself, and you can use the OnNotify Action logic as an example.