【问题标题】:How to show the select editor text but not value in Tabulator如何在制表符中显示选择编辑器文本但不显示值
【发布时间】:2018-11-19 02:36:11
【问题描述】:

作为editor select

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

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

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


【问题讨论】:

标签: tabulator


【解决方案1】:

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

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

您可以将相同的对象传递给 formatterParams,就像传递给 values 的属性一样强>editorParams

【讨论】:

  • 嗨,奥利!当我编辑具有editor: "autocomplete" 值的单元格时,单元格显示值而不是标题。 example遇到问题如何解决?
【解决方案2】:

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

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

{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 ""
                }

            }
    },

【讨论】:

    【解决方案3】:

    如果使用自定义格式化程序重新格式化供用户查看的内容,则可以使用以下链接。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多