如何使用 Tabulator 格式化 header 选定的过滤器值?
How can a header selected filter value be formatted using Tabulator?
这是 的跟进。它与使用 Tabulator 的 SELECT header 过滤器有关。接受的答案适用于格式化列表项
{
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>";
},
}
},
但是,一旦 selected,如果编辑器的 selected 值(?),那么格式就会出现,我们得到的格式与标题一起显示,而不仅仅是标题。我们认为我们可能需要一个自定义编辑器来解决这个问题,但不确定。我们不希望用户能够编辑 table 中的值,我们只想 selected 选项值显示而不使用 listItemFormatter 中的格式 HTML。
例如,如果 1.0 被 select 编辑,我们希望 1.0
显示在 selection 之后的过滤器框中,而不是 <b>1.0</b>
。 This JS Fiddle是用例子设置的。 Select 一个格式化的列表选项,您应该在 selection 之后的 select 框中看到格式化的值。如何删除 selected 值的格式?
您不能使用内置的 select 编辑器执行此操作,因为它使用输入元素显示 selected 值,而输入元素只能包含文本。
要获得此功能,您需要构建自定义编辑器。 Tabulator 的文档可以带您完成 How to build a custom editor
您甚至可以将其基于现有的 select 编辑器,您可以在其中找到 here
的代码
这是
{
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>";
},
}
},
但是,一旦 selected,如果编辑器的 selected 值(?),那么格式就会出现,我们得到的格式与标题一起显示,而不仅仅是标题。我们认为我们可能需要一个自定义编辑器来解决这个问题,但不确定。我们不希望用户能够编辑 table 中的值,我们只想 selected 选项值显示而不使用 listItemFormatter 中的格式 HTML。
例如,如果 1.0 被 select 编辑,我们希望 1.0
显示在 selection 之后的过滤器框中,而不是 <b>1.0</b>
。 This JS Fiddle是用例子设置的。 Select 一个格式化的列表选项,您应该在 selection 之后的 select 框中看到格式化的值。如何删除 selected 值的格式?
您不能使用内置的 select 编辑器执行此操作,因为它使用输入元素显示 selected 值,而输入元素只能包含文本。
要获得此功能,您需要构建自定义编辑器。 Tabulator 的文档可以带您完成 How to build a custom editor
您甚至可以将其基于现有的 select 编辑器,您可以在其中找到 here
的代码