如何将`headerFilter`与`editor:autolookup`一起使用?

时间:2019-01-02 18:01:58

标签: tabulator

我有桌子。一个字段是通用的,而另一个字段是查找。 我使用一些列表来显示可读值,而不是原始数字。

我尝试为此类列编写自定义headerFilter,但根本没有调用它。

尝试在下一个JS Fiddle代码的ID列和Country列中过滤数据:

var header_filter = function( headerValue, rowValue, rowData, filterParams ) {
  alert( 'Called' );
  headerValue =  headerValue.replace( / /g, '.*' );
  var re =  new RegExp( headerValue, 'i' );

  return rowValue.search( re ) >= 0;
}


//Build Tabulator
var table = new Tabulator("#example-table", {
    height:"311px",
    data: tabledata,
    columns:[
        {title:"ID", field:"id", width:40, headerFilter: true, headerFilterFunc: header_filter, },
        {title:"Country", field:"country_id", width:130, editor:"autocomplete", editorParams:{values: country_list, showListOnEmpty: true, }, formatter: "lookup", formatterParams: country_list,
        headerFilter: true, headerFilterFunc: header_filter,        
        },
    ],
});

我错了什么?如何在查找字段上使用自定义标头过滤器?

2 个答案:

答案 0 :(得分:0)

您不能。这是禁止的:

source

if(!(column.definition.headerFilter === "autocomplete" 
    || (column.definition.editor === "autocomplete" 
        && column.definition.headerFilter === true))){

答案 1 :(得分:0)

您可以在标头过滤器中使用am autocomplete过滤数据,只是不能实时过滤数据(即过滤器会随着您在自动填充中键入而变化),只有在从自动填充列表中选择一个值时,才会对其进行过滤