制表符:具有与单元格关联的值

Tabulator: Have a value associated with cell

我决定使用这个很棒的 Tabulator js 库,但我希望显示的每个单元格值都有不同的值。

喜欢

<td value="1">Bob</td>

我看到以下用于设置下拉菜单的选项

columns:[ 
        {title:"Name", field:"name", editor:"select", editorPramas: names
        ]

其中 names = { 1: 'Bob', 2: 'Jack'}

however this results in bob and Jack being displayed in the drop down and when Bob is selected it displays 1 in the cell value. However I want Jack and Bob to be in dropdown and when Bob is selected data cell gets value of 1 because I have columns values mapped to IDs which need to be stored in database.

这可以通过自定义来完成editorParams

columns:[ 
        {title:"Name", field:"name", editor:"select", editorPramas: myCustom
        ]

var myCustom = function(cell) {
    cell.getElement().setAttribute("value",2);
    ...
}

由此可以获取更改的单元格元素,并相应地更改它的任何属性。

我认为应该在下一个版本中考虑并通用此功能。 我为输入编辑器提出了一个 hack,但这应该使用新参数 elementProps

以通用方式完成

https://github.com/olifolkerd/tabulator/issues/1869