Tabulator 5.2 New editor List option/value

Viewed 277

In the new tabulator v5.2, the editor "select" was changed to "list", I have this code that was working fine in v5.1 but stop working in the new version, I hope someone can help me figured out what do I need to change to make it work again with this new version of tabulator.

Ex: in my table there are two columns with select dropdown values, the second column is dependent on the first. So if I select "Sales" in the first column, in the same row on the second column it will only show a list of "services" that belongs to the "Sales" department and so on.

In the code linked below you can see that in the first column when I click in a row in the "Dept" column, a list of values shows up, and if I select the value "Sales" it change to option "1".

{title:"DEPT", field:"dept", width:90, hozAlign:"left", editor:"list", editorParams:{values: {1:"Sales",2:"Service",3:"Bodyshop",4:"Carwash"}}},
{title:"WORK Type", field:"service", editor:"list", editorParams:{values: serviceList}},

jsfiddle

1 Answers

You can use the built-in lookup formatter to do that:

columns:[
    {title:"DEPT", field:"dept", 
     width:90, hozAlign:"left", 
     editor:"list", 
     editorParams:{
       values: {1:"Sales",2:"Service",3:"Bodyshop",4:"Carwash"}
     }, 
     formatter:"lookup", 
     formatterParams:{
       1:"Sales", 2:"Service", 3:"Bodyshop", 4:"Carwash"
     }},

Passing the same object of editorParams into the formatterParams would do your job.

Working Demo: https://jsfiddle.net/Mahesh1312/rzbxvym7/5/

Hope it helps!

Related