1

I am trying to use the jQuery sortable widget in a table. Is that feasible? Or is it made to be separate from a table?

This is the link to the jQuery widget-

http://jqueryui.com/sortable/#default

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

You can simply apply the sortable() method to the appropriate tbody element. There are bug fixes regarding width maintenance which are addressed here, so you should apply that to your tablesorter initialization.

var fixHelper = function(e, ui) {
    ui.children().each(function() {
        $(this).width($(this).width());
    });
    return ui;
};

$("#sort tbody").sortable({
    helper: fixHelper
}).disableSelection();
colonelsanders
  • 824
  • 6
  • 19
  • Thanks..but this is for sorting.Can I also implement the same for reoderer the table rows like what is shown in the link I posted above. – Pooja Biwalkar Oct 15 '14 at 00:10
  • Oh, my apologies. So you're looking for row reordering like [this](http://jsfiddle.net/bgrins/tzYbU/)? – colonelsanders Oct 15 '14 at 00:21
  • Yes..exactly like that! – Pooja Biwalkar Oct 15 '14 at 00:28
  • I have edited my answer so others aren't victims of my misunderstanding. Please note that this question has also been addressed before: http://stackoverflow.com/questions/1307705/jquery-ui-sortable-with-table-and-tr-width/1372954#1372954 – colonelsanders Oct 15 '14 at 00:43