本文介绍了如何使用完全匹配来过滤extjs存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为商店使用过滤器。问题是我想要返回一个完全匹配。例如:如果我在网格中过滤aa-1,它将显示aa-1和aa-1 ***,但如果我只想看到aa-1的所有内容。
我使用它来过滤:
监听器:{
itemclick:function(){
var data = grid.getSelectionModel()。selected.items [0] .data;
store.clearFilter();
store.filter('productsCat',data.productsCat);
}
}
我要做一个完全匹配?
解决方案
您可以在过滤器中使用正则表达式,以确保比较值是短语的结尾。或者使用filterBy()方法定义比较函数,例如:
store.filterBy(this,function(rec,id){
if(rec.get('thefieldtocompare')===你想要比较){
返回true;
}
else {
return false;
}
});
I am using a filter for a store. The problem is that i want to return an exact match. For example: if i am filtering for aa-1 in a grid it will show aa-1 and aa-1*** but if i want only see everything with aa-1.
I use this to filter:
listeners: {
itemclick: function () {
var data = grid.getSelectionModel().selected.items[0].data;
store.clearFilter();
store.filter('productsCat', data.productsCat);
}
}
What do i have to do to do an exact match?
解决方案
You could use a regular expression in the filter to perhaps ensure that the comparison value was the end of the phrase.
Either that, or use the filterBy() method to define a comparison function, e.g.:
store.filterBy(this, function(rec, id) {
if(rec.get('thefieldtocompare') === "what you want to compare against") {
return true;
}
else {
return false;
}
});
这篇关于如何使用完全匹配来过滤extjs存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!