2016-10-06 76 views
1

在我的Webix數據表中,一列從DataColletion中提取數據。問題在於列的過濾:似乎它與原始數據(包含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。提前致謝。

回答

1

過濾器適用於數據集,而不適用於鏈接集合中的模板或值。因此,需要如在Webix文檔描述create a custom filtering rule,即,在過濾器的compare屬性定義所需的圖案:

{ 
    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