【问题标题】:Filtering column's collection过滤列的集合
【发布时间】:2017-02-15 13:45:57
【问题描述】:

在我的 Webix 数据表中,有一列从 DataCollection 中获取数据。问题出在列的过滤中:似乎它适用于原始数据(包含 ID)并忽略了数据集合的值。如何更改此行为并按集合的值过滤数据表?

数据:

var mycollection = new webix.DataCollection({  
  data:[{
    id: '12',
    value: 'CollItem 1'
  }]
});

var mydata = [{
  id: 1, 
  name: 'Item 1', 
  troublesomeColumn: '12' // id of the CollItem 1
}];

配置:

columns:[{
  id: 'troublesomeColumn',
  collection: mycollection,
  header:{
    content:"textFilter"
  }
}],
data:mydata

Code snippet。提前致谢。

【问题讨论】:

    标签: javascript html datatable filtering webix


    【解决方案1】:

    过滤器适用于数据集,而不适用于链接集合中的模板或值。因此,您需要按照 Webix Docs 中的说明使用create a custom filtering rule,即在过滤器的compareproperty 中定义所需的模式:

      {
        content:"textFilter",
        compare:function(value, filter, obj){
          var colValue = mycollection.getItem(value).value;
          toFilter = colValue.toString().toLowerCase();                            
          filter = filter.toString().toLowerCase();
          return toFilter.indexOf(filter) !== -1;
        }
      }
    

    Updated snippet

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-07
      • 2014-03-12
      • 1970-01-01
      • 1970-01-01
      • 2019-02-15
      • 2023-01-16
      相关资源
      最近更新 更多