161
Views
5
Comments
Solved
[Drag-n-drop Sortable List] Where to Update the Table or is it even necessary?
drag-n-drop-sortable-list
Web icon
Forge asset by Renato Pauleta

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


updateWhere.png
2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP
Solution

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.


2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP

Hi Yosua,

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

Regards,

Daniel

UserImage.jpg
Yosua Witantra

Hello Daniel,


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



Yosua

DAOML.oml
2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP

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

UserImage.jpg
Yosua Witantra

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

2024-07-05 14-16-55
Daniël Kuhlmann
Ā 
MVP
Solution

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.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.