Multiple editors in handsontable

夙愿已清 提交于 2019-12-11 10:08:41

问题


I'm wondering how its possible to use multiple editors in handsontable.js library.

I'm using the columns option to specify each column attributes. Some of them show a list with the possible options for the cell:

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

In this case, it will generate the list of options in the source option.

Now, I would like to add another editor as per this other issue but I noticed that if I add it in the columns declaration then I lose the source option that generates the autocomplete list:

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

Any solution to this?

Reproduction of the issue


回答1:


Handsontable is using cascading configuration, which is way to provide configuration options for whole table, its columns or particular cells.

In your case specifying the type attribute (you mentioned it here) 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 (note that the autocomplete field do not work, but you should add another custom editor and not use the text one).



来源:https://stackoverflow.com/questions/29752993/multiple-editors-in-handsontable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!