SlickGrid select editor

前端 未结 5 1099
太阳男子
太阳男子 2020-12-10 05:57

I want to make a dynamically populated html select for a select cell. I extract some information from a database which is different for every row item. The problem is that t

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 06:29

    I can't add comments yet, but I need to add something to HeiN's answer.

    HeiN's answer works great, but I have data coming in that does not match my select options and I need to still display that data... so I have had to modify dataItemColumnValueExtractor in the options. This allows my original data to display if I do not have an option in the list to match.

            dataItemColumnValueExtractor: function(item, columnDef) {
                if(columnDef.editor == Slick.Editors.SelectOption){
                    return eval(columnDef.options)[item[columnDef.field]] != null ? eval(columnDef.options)[item[columnDef.field]] : item[columnDef.field];
                }else{
                    return item[columnDef.field];
                }
            }
    

    Hope this helps somebody later down the line.

提交回复
热议问题