设置制表符editorParams取决于要从中填充表的数据的值

问题描述 投票:0回答:1

所以我在通过制表符从数据库中获取数据后填充表。

例如,多维数据数组在每个索引[0- ..]中都有以下键和数据:

["code", "notation", "ztotal"]

我只会在表格中显示notationztotal,而不显示code。但是用户可以更改ztotalztotal的下拉列表有3种可能性,这取决于code的值。如果可能,我想做以下事情

...blah blah
    {title: "NOTATION", field: "notation", frozen:true}
    {title: "ZTOTAL", field: "ztotal", editor: "select", editorParams:{values:getDropDown(code)}}
...blah blah
...
function getDropDown(code) {
    if(code == 1) return dropdown1;
    else if(code == 2) return dropdown2;
    else return dropdown3;

我该如何实现?谢谢前进

javascript tabulator
1个回答
0
投票

想通了,猜想其他人会发现它有用。

{title: "ZTOTAL", field: "ztotal", editor: "select", editorParams:{values:getDropDown}}
.........
function getDropDown(cell) {
    code = cell.getRow().getData();
    // dropdown1,2,3 contains array for pull down menu
    if(code == 1) return dropdown1;
    else if(code == 2) return dropdown2;
    else return dropdown3;
}
© www.soinside.com 2019 - 2024. All rights reserved.