How can you format a Tabulator SELECT based header filters options?

后端 未结 1 1488
攒了一身酷
攒了一身酷 2021-01-28 13:15

We are using Tabulator (4.8.3) and have a SELECT based header filter on one column. It all works great except we are trying to add some formatting to some of the select options.

相关标签:
1条回答
  • 2021-01-28 13:55

    The problem you are facing is you are trying to style the labels for the select list values in the values array. The select editor uses an input element to show the selected value, therefor when you are selecting a value it is showing the label as text.

    The correct approach is to include the actual value in the label and then use the listItemFormatter to format the list as wanted, that way you store a plain text value against the label and display it as html:

    {
          title: "Topic",
          field: "topic",
          width: 120,
          headerFilterPlaceholder: "-- Select --", 
          headerFilter:"select", 
          headerFilterParams: {
              values: [1.0, 1.1, 1.2],
              listItemFormatter:function(value, title){ 
                  return "<b>" + title + "</b>";
              },
          }
    },
    
    0 讨论(0)
提交回复
热议问题