I have an Order__c field on the object which starts at index 1, and I'm just updating that field after every reorder.
Here's my inline javascript:
(function(skuid){
var $ = skuid.$;
$(document.body).one('pageload',function(){
var component = skuid.$C('MyComponentId'),
listContents = component && component.element.find('.nxlistcontents');
listContents.sortable({
placeholder: "uistatehighlight",
stop: function( event, ui ) {
var data = ui.item.data('object'),
model = data.list.model,
movedRow = data.row,
target = $(event.target);
target.children().each(function(index,tr){
var row = $(tr).data('object').row,
order = row.Order__c;
if (index + 1 !== order) {
model.updateRow(row,'Order__c',index+1,{initiatorId:component._GUID});
}
});
}
});
});
})(skuid);
Here's the table in action:
Matt Sones, Champion
 31,954 Points
Posted 3 years ago
mB Pat Vachon, Champion
 43,096 Points
 584 Points
Matt Sones, Champion
 31,944 Points
 584 Points
Karen Waldschmitt, Official Rep
 8,700 Points
Clarification question: Is this specific to when you use Matt's snippet or to tables in general?
Thanks!
Karen
 584 Points
Skuidward Tentacles (Raymond), Champion
 17,552 Points
Karen Waldschmitt, Official Rep
 8,700 Points
This is very cool!
Thanks for sharing with the community :)
Karen
 584 Points
mB Pat Vachon, Champion
 43,096 Points
// Sprint Work Drag & Drop reorder var component = skuid.$C('sk39dlIj483'), listContents = component && component.element.find('.nxlistcontents'); listContents.sortable({ placeholder: "uistatehighlight", stop: function( event, ui ) { var data = ui.item.data('object'), model = data.list.model, movedRow = data.row, target = $(event.target); target.children().each(function(index,tr){ var row = $(tr).data('object').row, order = row.Sprint_Rank__c; if (index + 1 !== order) { model.updateRow(row,'Sprint_Rank__c',index+1,{initiatorId:component._GUID}); } }); $.blockUI(); $.when( model.save() ) .done(function(){ $.unblockUI(); }); } });
 1,244 Points
 584 Points
 1,244 Points
Amy Dewaal, Official Rep
 8,230 Points
Have you tried tabbing over to the rich text area?
Thanks!
Amy
 584 Points
 584 Points
(function(skuid){
var $ = skuid.$;
$(document.body).one('pageload',function(){
var component = skuid.$C('johntt'),
listContents = component && component.element.find('.nxlistcontents');
listContents.sortable({
placeholder: "uistatehighlight",
handle: '.faellipsisv',
stop: function( event, ui ) {
var data = ui.item.data('object'),
model = data.list.model,
movedRow = data.row,
target = $(event.target);
target.children().each(function(index,tr){
var row = $(tr).data('object').row,
order = row.Order__c;
if (index + 1 !== order) {
model.updateRow(row,'Order__c',index+1,{initiatorId:component._GUID});
}
});
$.blockUI();
$.when(model.save()).done(function(){
model.updateData(function(){
$.unblockUI();
});
});
}
});
});
})(skuid);
Matt Sones, Champion
 31,954 Points
Amy Dewaal, Official Rep
 8,230 Points
I'm glad you found a workaround, and thanks for sharing it with the community!
Thanks!
Amy
 2,798 Points
"I have an Order__c field on the object which starts at index 1, and I'm just updating that field after every reorder."
 584 Points
 488 Points
 584 Points
 488 Points
 4,940 Points
 4,940 Points
In the stopHelper function I found the current table page and page size to get my start number.
component = skuid.$C(tableId), currentPage = component.list.currentPage, currentPageSize = component.list.currentPageSize, startNumber = currentPage * currentPageSize;
Then, I add that startNumber to the updateRow function:
model.updateRow(row, orderByFieldApiName, index + 1 + startNumber, { initiatorId: component._GUID });
 4,940 Points
if (isNaN(startNumber)) startNumber = 0;
Karen Waldschmitt, Official Rep
 8,700 Points
 80 Points
 4,940 Points
 80 Points
 1,304 Points
Related Categories

Javascript Snippets
 59 Conversations
 122 Followers

Custom Components
 6 Conversations
 6 Followers