handsontable 中的多个编辑器

Multiple editors in handsontable

我想知道如何在 handsontable.js 库中使用多个编辑器。

我正在使用 columns 选项来指定每个列的属性。 其中一些显示了一个列表,其中包含单元格的可能选项:

{
    data: 3,
    type: 'autocomplete',
    source: function (query, process) {
        response = JSON.parse($('#options').val());
        process(response);
    },
    strict: false,
    allowInvalid: true,
},

在这种情况下,它将在source选项中生成选项列表。

现在,我想按照 添加另一个编辑器,但我注意到如果我将它添加到列声明中,那么我将丢失生成自动完成列表的源选项:

{
    //START
    data: 3,
    type: 'autocomplete',
    source: function (query, process) {
        response = JSON.parse($('#start_array').val());
        process(response);
    },
    strict: false,
    allowInvalid: true,
    editor: LoggingEditor //added here
}

有什么解决办法吗?

Reproduction of the issue

Handsontable 使用 cascading configuration,这是为整个 table、其列或特定单元格提供配置选项的方法。

在您指定 type 属性的情况下(您提到它 ) trumps the top-level editor: LoggingEditor property. To use a custom editor you have to either not specify a type (because the default is text) or add the editor property to all column definitions. I've edited your example to utilize both methods in this fiddle(请注意,自动完成字段不起作用,但您应该添加另一个自定义编辑器,而不是使用文本编辑器)。