3

iam using jquery ui 10.1.3 and when dragging the rows vertically there is small shift in the width of the dragged row. and when looked at the forums looks like the below bug represents it. My table has non visible columns (hidden columns).

Do we have any fix for this ?

http://bugs.jqueryui.com/ticket/9979

https://github.com/jquery/jquery-ui/commit/9711c54c6d3d7ecffa9bfccc205522be1f4aa148

4
  • Can you make a JSFiddle? Commented May 14, 2014 at 16:35
  • if we look at this link . jsbin.com/nohovilu/3/edit . In the first there is hidden columns and when dragging we can see there is a small shift vertically. let me know if that doesnt make sense. Commented May 14, 2014 at 17:14
  • I think I figured it out. Look at my answer below. Commented May 14, 2014 at 17:49
  • wondering whether the answer solved the issue or not… :) Commented Jun 27, 2014 at 10:13

1 Answer 1

5

The issue here is that jQueryUI is adding a placeholder row, with the class of ui-sortable-placeholder. The placeholder is set with visibility:hidden. This means that you can't see it, but it takes up the space it normally would if it were visible.

In this JSBin, the second column of every row is hidden. That means that the second column won't take up any space. The problem here is, when jQueryUI creates the placeholder column, it does not hide the second column.

Look at this JSFiddle and you'll see what I mean. The placeholder has an added blue column in between the first and second columns.

You could get rid of this multiple ways. One, by hard coding the CSS to hide the second column, as shown here, and in this code:

.ui-sortable-placeholder td:nth-child(2)
{
    display:none;
}

Another way is to add some code to hide the columns in the placeholder that are hidden in the real table, as shown here, and in this code:

sort: function (e, ui) {
    ui.placeholder.find('td').each(function (key, value) {
        //alternative: if (!ui.item.find('td').hasClass('hidden')) $(this).show();
        if (ui.helper.find('td').eq(key).is(':visible')) $(this).show();
        else $(this).hide();
    });
}
Sign up to request clarification or add additional context in comments.

3 Comments

Strange your fiddle works but the same code when i use its still the same issue
How many columns are in your table? Which columns are hidden?
There were around 78 odd columns and out of which 70 columns are hidden in the worst scenario.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.