如何使用行数据中的自动完成值

时间:2019-07-08 02:16:06

标签: tabulator

我正在尝试在http://tabulator.info/docs/4.1/edit使用扩展版本的自动完成示例。在编辑过程中,自动完成值不会列出或显示。

我尝试了多种指定自由文本的组合。

editorParams: {
    showListOnEmpty: true, //show all values when the list is empty,
    freetext: true, //allow the user to set the value of the cell to a free text entry
    allowEmpty: true, //allow empty string values
    values: function (cell) {
        var rowData = cell.getRow().getData();
        if ("undefined" !== typeof (rowData["Options"])) {
            const values = { values: rowData["Options"] };
            console.log(values);
            return values;
        }
    },
    editable: function (cell) {
        return cell.getColumn().getDefinition().title !== 'Key';
    }
}

期望是从rowdata [“ Options”]查看预设的自动完成值,或者在不存在Options时允许使用自由文本。

以下是示例数据

[{
    "Label": "Owner – Person",
    "Key": "owner-person",
    "Value": "Me"
},
{
    "Label": "Data Source",
    "Key": "data-source",
    "Value": "Index",
    "Options": [
        "Study",
        "Protocol",
        "Final Paper",
        "Index",
        "Strcutured Data"
    ]
}]

位于https://codepen.io/anon/pen/NZOXZX的电笔示例

0 个答案:

没有答案