【问题标题】:jQuery UI Sortable column width reduces while dragging a rowjQuery UI 可排序列宽在拖动行时减小
【发布时间】:2014-05-17 04:19:02
【问题描述】:

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

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;
}
*/

任何人都可以提出解决方案。

【问题讨论】:

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


【解决方案1】:

我不能声称完全理解这个插件的工作原理,但是对“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('');                   
        },

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

【讨论】:

  • 感谢您的回复,实际上我面临的问题与以下 jquery 错误中的问题相同。bugs.jqueryui.com/ticket/9185。我们有固定的表格布局,因此在拖动其他行时宽度正在缩小,我们无法将表格布局更改为自动,所以请帮助我解决这个 jquery 错误的代码。
猜你喜欢
  • 2011-12-11
  • 2012-06-20
  • 2018-07-27
  • 1970-01-01
  • 2023-03-13
  • 1970-01-01
  • 2014-07-02
  • 1970-01-01
  • 2016-09-14
相关资源
最近更新 更多