本文介绍了jQuery UI Sorting with table and tr width的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在使用可排序的jQuery UI,以使我的表网格可排序.该代码似乎可以正常工作,但是因为我没有在td s中添加宽度,所以当我拖动tr时它会缩小内容.

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 tds, when I drag the tr it shrinks the content.

例如;如果我开始拖动时表格行为500px,则该行变为300px.我认为这是因为没有在网格中定义宽度而发生的.那是因为我正在为td使用两个类(fixliquid).

For example; if my table row is 500px when I start dragging, it becomes 300px. I assume that's happening because no width is defined in the grid. That's because I am using two classes for the tds (fix and liquid).

fix类使td等于内容宽度,而liquid使td宽度为100%.这是我的网格表方法,无需为td s分配宽度.

The fix class makes the td equal to the content width and liquid makes the td width 100%. It's my approach for grid table without having to assign width to tds.

有什么主意如何利用我的方法进行可排序的工作?

Any idea how to make sortable work with my approach?

推荐答案

我找到了答案此处.

我稍作修改以克隆行,而不是在原始行上增加宽度:

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;
  },

这篇关于jQuery UI Sorting with table and tr width的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 15:11