繁体   English   中英

为tabulator中的每一行动态设置列编辑器

[英]Dynamically set the column editor for each row in tabulator

我有一个客户,每行都有元数据,描述列中的数据类型。 是否可以为每一行的列设置不同的编辑器?

var tab = new Tabulator('#tabId', {
    data: data,
    layout: 'fitColumns',
    columns: [
        {
            title: 'Name',
            field: 'LocationName',
        },
        {
            title: 'Field',
            field: 'Field',
            editor: (cell, onRendered, success, cancel, editorParams) => {
                // is it possible to just return one of the built in editors here, if so how?
                // I only need text, date, checkbox built-in types, but need to determine which 
                // one dynamically based on data in the row.
            }
        }
    ]
});

这对于标准编辑器是不可能的,它们必须按列定义,但您可以创建一个自定义编辑器,该编辑器可以返回多个编辑器中的一个,并根据行数据选择要返回的一个。

您可以从 repo 中的src\\js\\modules\\edit.js文件中获取内置编辑器的源代码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM