大佬教程收集整理的这篇文章主要介绍了javascript – 将包含应用于jQuery UI可排序表可防止将高行移动到最后位置,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
jQuery(function($) { $("#rows")@L_262_4@rtable({ handle: ".handle",axis: "y",containment: "#main-table",Helper: function(e,row) { // From http://www.paulund.co.uk/fixed-width-sortable-tables. // Sets the width of each cell to be its original width. // This prevents the row collapsing into a narrower stub when being dragged. row.children().each(function() { $(this).width($(this).width()); }); return row; } }); });
但是,当存在具有多个线高的行时,包含不会按预期运行:当拖动较大的行时,表的高度会减小,并且包含会收缩得更多,使得大行无法移动到底部的表.其他行工作正常.
可以在此处找到显示此行为的JSfiddle:https://jsfiddle.net/AndrewBennet/rc5pnazc/3/
这是已知/预期的行为吗?有没有解决方法?
您可以做的一件事是在start事件上调整这些值,以便它们在从计算中删除行之前匹配表的状态.您可以通过sortable的实例方法访问它们.
如果您想要更精确,您也可以调整此包含属性的顶部坐标,以便考虑点击偏移.
像这样例如:
jQuery(function($) { $("#rows")@L_262_4@rtable({ handle: ".handle",containment: '#main-table',start: function(e,ui) { // get the instance of the sortable. // instance method is new to jquery ui 1.11,for prevIoUs versions // you can use $(this).data()['ui-sortable']; var sort = $(this)@L_262_4@rtable('instance'); // this makes the placeholder fit with the row that's being dragged ui.placeholder.height(ui.Helper.height()); // containment property of the sortable instance is not the same // as the containment option. The property is calculated // from the option. You need to adjust bottom coordinates // to takE into account the row you just removed from it and the click offset. sort.containment[3] += ui.Helper.height() * 1.5 - sort.offset.click.top; // Since your handle is centered,and pointer coordinates are used // for sortable,but top coordinates are used for containment // you can have issues with top row. AdjusTing with the click offset // will resolve the issue. sort.containment[1] -= sort.offset.click.top; },row) { // From http://www.paulund.co.uk/fixed-width-sortable-tables. // Sets the width of each cell to be its original width. // This reverts the default behavIoUr of the row collapsing into a narrower stub when being dragged. row.children().each(function() { $(this).width($(this).width()); }); return row; } }); });
以上是大佬教程为你收集整理的javascript – 将包含应用于jQuery UI可排序表可防止将高行移动到最后位置全部内容,希望文章能够帮你解决javascript – 将包含应用于jQuery UI可排序表可防止将高行移动到最后位置所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。