首页 文章

如何在Tabulator中显示选择的编辑器文本但不显示值

提问于
浏览
1

作为editor select

values: {
    "steve": "Steve Boberson",
    "bob": "Bob Jimmerson",
    "jim": "Jim Stevenson",
}

我可以发现这个对象键将是单元格数据的值(see the picture),但它可以与html select类似,我的意思是选择选项文本是针对用户的,而值是针对开发人员的 .

<select>
    <option value="steve">Steve Boberson</option>
</select>

3 回答

  • 0

    我使用自定义格式化程序解决了这个问题 . “metricList”是包含由DB填充的标签和值的变量 . 所以这些值都在“metricList”中 .

    然后自定义格式检查单元格中是否有值,如果是,则找到值的Label并返回该值 .

    {title:"Metric", field:"metricid", editor:"select", download:false,
                editorParams: {
                    values: metricList
                },
                formatter:function(cell, formatterParams, onRendered) {
                    if (cell.getValue() > 0) {
                        return metricList.find(obj => obj.value == cell.getValue()).label
                    } else {
                        return ""
                    }
    
                }
        },
    
  • 0

    您应该使用内置的 lookup 格式化程序来执行此操作:

    {title:"Example", field:"example", formatter:"lookup", formatterParams:{
        "small": "Cute",
        "medium": "Fine",
        "big": "Scary",
    }}
    

    您可以将相同的对象传递到 formatterParams ,就像 editorParamsvalues 属性一样

  • 0

    如果使用自定义格式化程序重新格式化内容以供用户查看,则可以使用它 .

    Visit https://jsfiddle.net/allensimth/zb6engfr
    

相关问题