2015-04-20 49 views
1

我想知道如何在handsontable.js庫中使用多個編輯器。多個編輯器在handsontable

我正在使用columns選項指定每個列屬性。 他們中的一些展示列表與細胞可能的選項:

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

在這種情況下,它會生成在source選項選項列表。現在

,我想補充另一個編輯按this other issue但我注意到,如果我在列聲明中加入它,然後我失去生成自動完成列表中的源選項:

{ 
    //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

回答

1

Handsontable使用cascading configuration,這是方式提供完整的表,它的列或特定細胞配置選項。

在你的情況下,指定type屬性(你提到它的here)勝過頂級editor: LoggingEditor屬性。要使用自定義編輯器,您必須不指定類型(因爲默認爲文本),或者將editor屬性添加到所有列定義。我編輯了您的示例,以便在this fiddle中使用這兩種方法(請注意,自動填充字段不起作用,但您應該添加另一個自定義編輯器而不使用文本)。

+0

所以,沒有任何方法可以使用編輯器,同時使用'type:autocomplete'? – Alvaro

+0

我創建了這個問題的複製[這裏](http://jsfiddle.net/fws1vc5e/21/)。正如你所看到的,我爲每一列使用了一個「編輯器」和「類型」屬性。然而,自動完成功能不起作用。 – Alvaro

+0

如果從'AutocompleteEditor'擴展'type:'autocomplete''列,它[將工作](http://jsfiddle.net/hb5ujwkn/)。查看HOT wiki和[編輯器實現](https://github.com/handsontable)上的[custom editors](https://github.com/handsontable/handsontable/wiki/Custom-cell-editor)頁面/ handsontable /樹/主/ SRC /編輯)。 –