代码之家  ›  专栏  ›  技术社区  ›  geco17

AUI数据表可排序选择行

  •  0
  • geco17  · 技术社区  · 7 年前

    我正在使用AUI库生成可排序的数据表。我希望单元格是可选的(通常是纯文本,没有javascript事件绑定)。

    columns 定义为

    var columns = [
        {
            key: "col1",
            label: "Column 1",
            sortable: true
        },
        {
            key: "col2",
            label: "Column 2",
            sortable: true
        },
        ...
    ];
    

    如果我用类似的东西

    var myDatatable = new A.DataTable.Base({
        columnset : columns,
        recordset : data
    });
    

    我可以选择单独的行,但没有排序。

    如果我使用

    var myDatatable = new A.DataTable({
        columnset : columns,
        recordset : data
    });
    

    表是可排序的,但我不能用普通的鼠标按+拖动来选择数据。

    我这里缺什么?

    我尝试添加以下插件

    plugins: [{
        cfg: {
            type: "rows"
        },
        fn: A.Plugin.DataTableHighlight
    },
    {
        cfg: {
            selectRow: true,
            selectColumn: true
        },
        fn: A.Plugin.DataTableSelection
    }]
    

    但如果选择一个简单的选项,就没有运气了。作为参考,AUI文件是 here . 请注意,基本示例执行我需要的减号排序,而实际示例需要双击(允许编辑)单元格才能选择/复制内容。

    请帮忙。谢谢!

    1 回复  |  直到 7 年前
        1
  •  0
  •   geco17    7 年前

    我通过清除mousedown和mouseup事件并重写 getEditor 功能和排序仍然有效。

    /* text is not selectable otherwise */
    myDatatable.get("contentBox").purge(true, "mousedown");
    myDatatable.get("contentBox").purge(true, "mouseup");
    /* suppress getEditor */
    A.DataTable.prototype.getEditor = function() {};
    
    推荐文章