• Extjs store filter


    下文均已服务器端查询为例,一般我们载入数据通过 store.load()

    如果要过滤数据则使用

    store.filter('Fcomego','dwstr')
    //提交数据为 filter:[{"property":"Fcomego","value":"dwstr"}]
    store.filter([{
    		property : "pages",
    		value : "1111"
    	}, {
    		property : "title",
    		value : "Ext"
    	}]);
    
    // 向服务器提交的数据格式为  filter:[{"property":"pages","value":"1111"},{"property":"title","value":"Ext"}]
    
    Ext.create('XS.store.GridStore', {
                extraParams: {tf_parentId: manRecId},
                filters: [{
                    property: 'tf_fpHDIDs',
                    //value: ',' + manRecId + ',', 
                    operator: 'like'
                }],
      listeners: {
    'beforeload': {
    fn: function (ds) {
           //动态修改filter参数
    ds.getFilters().getByKey('tf_fpHDIDs').setValue(',' + this.get('mainRecId') + ',')
    }, scope: this
    }
    });
    // 红色对象,可以有任意个成员,并且都会以GET方式提交到服务器

    已下下转至: Extjs中store的filter和filterBy的用法,客户端过滤

    在Extjs设计界面,很多时候并不需要将所有的数据都显示到界面上,这样子我们可以通过在创建store时添加filter属性或调用filterBy方法实现。

    1、设计时设置filter属性

    //数据模型Model
    Ext.define('model.AppProject', {
        extend:'Ext.data.Model',
        fields:[
             {name:'indexIdApp',mapping:'application>indexId'},
           {name:'orgNameApp', mapping:'application>orgName'},
           {name:'verifyResultApp', mapping:'application>verifyResultApp',type:'int'}
        ]
    });

    //创建store
    var proAppStore = Ext.create('Ext.data.Store', {
        model: 'model.AppProject',
        autoLoad:true,
        filterOnLoad:true,
        proxy:{
            type: 'ajax',
            method:'post',
            extraParams:{headValue:RetrieveAppProject,bodyValue:"indexId:*^^",handleMsg:AppRetrieveMsg},
            url : 'HTPApp.CSP.ServiceProxy.cls',
            reader:{
            type:'xml',
            record:'EvaluateOrg',
            totalRecords:'@total'
            }
          },
         filters: [
            {//添加过滤掉未审核和审核未通过的申请
                property: 'verifyResultApp',
                value   : /^+?[1-9]*$/

            }
        ]
        
    });

    以上代码中在创建的时候设置filters时,限定model中verifyResultApp为正整数,其中用到正则表达式,值得注意的是,我们需要在store中添加filterOnLoad:true,这样在加载的时候这个过滤就会有效果。

    2、在需要过滤的时候调用filterBy方法

    proAppStore.filterBy(function(record) { 
                          return record.get('orgNameApp') == "IT";   
                      });

    如上代码我们就可以得到'orgNameApp'为IT的数据

    当然多个条件限制时可以在return的时候用&&连接

     return record.get('verifyResultApp') == 0&&record.get('orgNameApp') == orgNameQuik

  • 相关阅读:
    Java实现 LeetCode 173 二叉搜索树迭代器
    PHP array_reverse() 函数
    PHP array_replace_recursive() 函数
    PHP array_replace() 函数
    PHP array_reduce() 函数
    PHP array_rand() 函数
    C# 通配符转正则
    win10 uwp 验证输入 自定义用户控件
    win10 uwp 验证输入 自定义用户控件
    win10 uwp 验证输入 自定义用户控件
  • 原文地址:https://www.cnblogs.com/xsSystem/p/3142924.html
Copyright © 2020-2023  润新知