4.Ext JS Ext.data.Store本地过滤

  1. 云栖社区>
  2. 博客>
  3. 正文

4.Ext JS Ext.data.Store本地过滤

一线分享 2016-12-13 13:42:38 浏览277
展开阅读全文
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/inforstack/article/details/53608732
 var myStore = Ext.create('Ext.data.Store', {
      fields: [
         {name: 'firstName', type: 'string'},
         {name: 'lastName',  type: 'string'},
         {name: 'age',       type: 'int'},
         {name: 'eyeColor',  type: 'string'}
     ],
     data : [
         {firstName: 'Peter',   lastName: 'Venkman'},
         {firstName: 'Egon',    lastName: 'Spengler'},
         {firstName: 'Ray',     lastName: 'Stantz'},
         {firstName: 'Winston', lastName: 'Zeddemore'}
     ]
 });
 
 //如果不清空,将在上次过滤的基础上再次过滤
 myStore.clearFilter();
 
 //filter with a single field
myStore.filter('firstName', 'Don');

//filtering with multiple filters
myStore.filter([{
        property : 'firstName',
        value    : 'Don'
    },{
        property : 'lastName',
        direction: 'Griffin'
    }]);

//自定义过滤
myStore.filterBy(function(record){
	return record.get('firstName') == 'Don';
})

网友评论

登录后评论
0/500
评论
一线分享
+ 关注