views:

2419

answers:

2

Hi i am using jquery ui sortable to make my table grid sortable.The code seems to work fine but because i am not using width to TDs when drag the TR srink the content.

For examle IF my table row is 500px when start drag it becames 300px.I assume thats happening because no width is defined at grid.Thats because i am using 2 class for TDs (fix and liquid).

The fix class make the TD equal to content width and liquid makes the TD width 100%. Its my approach for grid table without have to assign width to TDs.

Any ideas to make sortable work with my approach.

Thanks

A: 

I might be a bit off here, but can't you just give the table or tr a fixed width?

Fabian
That was my first thought BUT its not working
The thing i'd try next would be adding the following flag.$("#id").sortable({ forceHelperSize: true });Sorry can't test it at the moment.
Fabian
Nope, its not working. I tried helper: 'clone' but its not working either
+7  A: 

I found the answer here.

I modified it slightly to clone the row, instead of adding widths to the original:

  helper: function(e, tr)
  {
    var $originals = tr.children();
    var $helper = tr.clone();
    $helper.children().each(function(index)
    {
      // Set helper cell sizes to match the original sizes
      $(this).width($originals.eq(index).width())
    });
    return $helper;
  },
Dave Miller