Finally implemented jQuery .sortable() to enable drag-and-drop reordering on a skuid table. turned out to be much simpler than I expected!
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(‘.nx-list-contents’);
listContents.sortable({
placeholder: “ui-state-highlight”,
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:
Sort Table with Drag and Drop
This topic has been closed for replies.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.