简体   繁体   中英

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-..] -

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

I will only show notation and ztotal in the table, not code . But user can change ztotal . There is 3 possibility for the dropdown list for ztotal which depends on the value of 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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM