拖动行时,jQuery UI可排序列宽减小

时间:2014-04-04 17:55:26

标签: jquery user-interface jquery-ui-sortable

请帮助解决这个问题。在这里找到小提琴代码:

jsfiddle.net/srikanthsvr82/mZc7V/4

正在发生的事情是,当我拖动一行时,拖动的行是全宽并且看起来很好,但其他行收缩/列宽减小。我一直在尝试所有选项,你可以在注释代码中看到,但没有一个正在运行:

/*
start: function(event, ui){
  ui.placeholder.width(ui.item.width()).height(ui.item.height());
},
helper: function(e, tr){
  tr.children().each(function() {
    $(this).width($(this).width());
  });
  return tr;
  $("td").each(function () {
    $(this).css("width", $(this).width());
  });
  var $originals = tr.children();
  var $helper = tr.clone();
  $(tr.parent()).find('tr').each(function(index){
    $('td', this).each(function(index){
      $(this).css('width', $helper.eq(index).width());
    });
  });
  $helper.children().each(function(index){
    //Set helper cell sizes to match the original sizes
    $(this).width($originals.eq(index).width());
  });
  return $helper;
}
*/

任何人都可以建议解决方案。

1 个答案:

答案 0 :(得分:0)

我不能声称完全理解这个插件是如何工作的,但是对“helper”参数的以下更改修复了这个问题:

        helper: function(e, tr)
        {
            var myHelper = [];
            myHelper.push('<div style="width:10px;"><table>');
            myHelper.push($(tr).html());
            myHelper.push('</table></div>');                    
            return myHelper.join('');                   
        },

基本上,将帮助器包装在与表的第一列宽度相同的容器中。

相关问题