38
Views
1
Comments
[Drag and Drop Sortable Table] Only works for only 1 Table in a screen
drag-and-drop-sortable-table
Reactive icon
Forge asset by Gerald Emmanuel Malaca
Application Type
Reactive

Doesn't trigger the Update Event when more than one table are using this component in the same screen, even in if they are in separate blocks.

It's because on your GetUpdatedOrder script you have: 

var updatedrows = document.querySelectorAll('tbody.ui-sortable tr');

which means it's getting rows from every sortable table included in the screen besides the one who is being "sorted" and getting undefined values from those other tables which is giving a "Failed to deserialize JSON" error.


My solution (this way it will work for one table and also more in the same screen):


Since you already have the TableId, you should change it to:


var updatedrows = document.querySelectorAll('#' + TableId +' tbody.ui-sortable tr');


Do the same thing in your SetDragAndDrop script: 

  var rowlist = document.querySelectorAll('#' + TableId +' tbody.ui-sortable tr' );



UserImage.jpg
Gerald Emmanuel Malaca

Hi Sofia, Thank you  for the suggested code change. 

I have changed the javascript code now to make it work in multiple tables within the same screen. 

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