Ext.data.Store.find的匹配模式,
也就是说,store.find(‘find’, ‘a’);
如果store里面有两行record,
一行的find列是’ab’,
一行的find列是’a',
那么会返回先匹配到的那一行,而不是你想要的’a',
如果你想用find方法获得你给定的值相等的行,如果要用精确匹配,使用Ext.data.Store.findExact()方法
这个方法是这样实现的
findExact: function(property, value, start){
return this.data.findIndexBy(function(rec){
return rec.get(property)
}, this, start);
},
注意这里面的匹配使用的是恒等===,
在Ext官网的手册里面,上面提到的两个函数的说明,都是下面这句,
Finds the index of the first matching Record in this store by a specific field value.
Finds the index of the first matching Record in this store by a specific field value.
这里Ext可能疏忽了
本文摘自:http://blog.sina.com.cn/s/blog_454fbf740100vi1l.html ;在此表示感谢,的确解决了项目中隐藏的bug!
本文介绍了Ext.data.Store.find与findExact的区别及应用场景。find方法在遇到首个匹配项时即返回,而findExact则用于精确匹配指定值。文章还强调了字段类型配置的重要性,并提供了findExact方法的具体实现。
2165

被折叠的 条评论
为什么被折叠?



