制表器可移动行 - rowPositioning() 在移动到组顶部时不更新放在组标题上

如何解决制表器可移动行 - rowPositioning() 在移动到组顶部时不更新放在组标题上

首先,感谢您迄今为止为 Tabulator 所做的出色工作 - 我一直在一个副项目中使用它,目的是在这些天的一个实际项目中使用它。我想说我是一名中级 Tabulator 用户/程序员,我发现可能是一个错误,但很高兴被证明是错误的。

问题:

当通过点击和拖动移动行时,当行移动到组的开头(通过拖放组标题)时,行定位 row.getPosition() 返回不正确的行值。我已经设置了下面链接的 JS 小提琴来演示这种行为。在此示例中,您可以通过将“Mary”行之一拖动到蓝色组的顶部来重现错误。表数据似乎没有随着更改而更新。

我尝试了变通方法,但找不到,这对我的目的很重要,因为我将行顺序存储在数据库中以重新加载页面

预期行为: 通过在组标题上拖放将行移动到组顶部时,会导致正确的行定位 row.getPosition()

Jsfiddle example here

先谢谢你!

解决方法

我相信我已经回答了我自己的问题。我将在 Github 页面上报告错误。简而言之,我已经解决了对 Tabulator.js 中的 moveRowInArray 函数的微小更改。

第二个调整在技术上改变了预期的行为,因为它将行添加到组的前面,尽管这在我看来效果更好并且与第一个柚木兼容。但是可以重写以保留推送而不是狗屎,我敢肯定。

第 4105 行

RowManager.prototype._moveRowInArray = function (rows,from,to,after) {

    var fromIndex,toIndex,start,end;

    if (from !== to) {

        fromIndex = rows.indexOf(from);

        if (fromIndex > -1) {

            rows.splice(fromIndex,1);

            toIndex = rows.indexOf(to);

            //////////////////////////////////////// jarb99 edit below

            if (to.type == "group" && after) {

                // splice above first row of group

                toIndex = rows.indexOf(to.rows[0]);

                after = false

            }

            //////////////////////////////////////// jarb99 edit above

            if (toIndex > -1) {

                if (after) {

                    rows.splice(toIndex + 1,from);
                } else {

                    rows.splice(toIndex,from);
                }

            } else {

                rows.splice(fromIndex,from);
            }
        }

        //restyle rows

        if (rows === this.getDisplayRows()) {

            start = fromIndex < toIndex ? fromIndex : toIndex;

            end = toIndex > fromIndex ? toIndex : fromIndex + 1;

            for (var _i4 = start; _i4 <= end; _i4++) {

                if (rows[_i4]) {

                    this.styleRow(rows[_i4],_i4);
                }
            }
        }
    }
};

第 20082 行

    Group.prototype.insertRow = function (row,after) {
    var data = this.conformRowData({});

    row.updateData(data);

    var toIndex = this.rows.indexOf(to);

    if (toIndex > -1) {
        if (after) {
            this.rows.splice(toIndex + 1,row);
        } else {
            this.rows.splice(toIndex,row);
        }
    } else {
        if (after) {
            // this.rows.push(row); // jarb99
            this.rows.unshift(row); // jarb99
        } else {
            this.rows.unshift(row);
        }
    }

    row.modules.group = this;

    this.generateGroupHeaderContents();

    if (this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.options.columnCalcs != "table") {
        this.groupManager.table.modules.columnCalcs.recalcGroup(this);
    }

    this.groupManager.updateGroupRows(true);
};

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?