I am using jQuery UI sortable to make my table grid sortable. The code seems to work fine but because I am not adding width to td
s, when I drag the tr
jsFiddle
After a lot of different attempts I just tried a simple solution which completes the solution of Dave James Miller to prevent the table of shrinking while dragging the largest row. I hope it will helps :)
// Make sure the placeholder has the same with as the orignal
var start = function(e, ui) {
let $originals = ui.helper.children();
ui.placeholder.children().each(function (index) {
$(this).width($originals.eq(index).width());
});
}
// Return a helper with preserved width of cells
var helper = function(e, tr) {
let $helper = tr.clone();
let $originals = tr.children();
$helper.children().each(function (index) {
$(this).width($originals.eq(index).outerWidth(true));
});
return $helper;
};