[英]Set tabulators editorParams depending on the value of data from which table is populated
So i am populating a table after getting data from database by tabulator.所以我在通过制表器从数据库中获取数据后填充一个表。
For example, the multidimensional data array has following keys and data in every index[0-..] -例如,多维数据数组在每个索引 [0-..] 中都有以下键和数据 -
["code", "notation", "ztotal"]
I will only show notation
and ztotal
in the table, not code
.我只会在表格中显示
notation
和ztotal
,而不是code
。 But user can change ztotal
.但用户可以更改
ztotal
。 There is 3 possibility for the dropdown list for ztotal
which depends on the value of code
. ztotal
的下拉列表有 3 种可能性,这取决于code
的值。 I want to do something as below, if possible如果可能的话,我想做如下的事情
...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;
How do i achieve this?我如何实现这一目标? Thanks is advance
谢谢是提前
Figured it out, guessed someone else will find it useful.想通了,猜别人会发现它有用。
{title: "ZTOTAL", field: "ztotal", editor: "select", editorParams:{values:getDropDown}}
.........
function getDropDown(cell) {
code = cell.getRow().getData()["field_name"];
// dropdown1,2,3 contains array for pull down menu
if(code == 1) return dropdown1;
else if(code == 2) return dropdown2;
else return dropdown3;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.