【问题标题】:ExtJS store filter is being sent not in fullExtJS 存储过滤器未完整发送
【发布时间】:2014-10-28 18:51:54
【问题描述】:

我有一个与远程数据库模型同步的商店。我需要应用远程过滤。问题是,如果我在配置选项中设置过滤器,则过滤器正在发送(加载或同步)但未完全发送。 商店

var RegularItemsStore=Ext.create("appMain.Store.UniversalStore",{
     model: 'OrderModel',
     modelName:'Order2',  
     autoSync: true, 
     filters:  [{ "property" : "storeId", "value": 0 , "type": "numeric",  "operator": "="}, 
});

在 Http ajax 请求中,这个过滤器通过 ONLY "property" : "storeId", "value": 0"type": "numeric", "operator": "=" 被遗漏;在网络开发工具中:

Query String Parameters 
    r:backend/index
    Table:Order2
    log:0 
    ...
    filter:[{"property":"storeId","value":0}]

如果我在与存储相关的代理上设置过滤器,则过滤器将不变地传递给服务器(以正确的方式): 代理配置

this.proxy =         
{  
    url:  "index.php?r=backend/index&Table=" + this.modelName + this.params,
    reader: { 
         root: "result.data",
         totalProperty: "result.count",     
         type: "json",
         metaProperty: 'myMetaData', // config for metaData:  
    }, 
    actionMethods: {
          read: 'GET', update: 'POST'
    },   
    ...
};

过滤应用

Ext.each(ItemStoreArray, function(store){
   var filter = [ { property: 'contractorId', value: ContractorSelectedId ,  operator: '=', type: 'numeric' }, { property: 'userId', value: UserId ,  operator: '=', type: 'numeric' }];  
   store.getProxy().setExtraParam('filter' , Ext.JSON.encode(filter) ); 
   store.load();        //console.dir(store);               
});

如何解决?我应该在商店初始化中为代理设置一个永久过滤器吗?

更新

按照 Alexander 的建议,我已覆盖解决问题的代理配置参数:

encodeFilters: function(filters) {
     var min = [],
     length = filters.length,
     i = 0;

     for (; i < length; i++) {
        min[i] = {
             property: filters[i].property,
             value   : filters[i].value,
             operator   : filters[i].operator, // added
             type   : filters[i].type, // added
         };
     }
     return this.applyEncoding(min);
},  

【问题讨论】:

    标签: extjs filter proxy store


    【解决方案1】:

    您可以在您使用的代理中覆盖encodeFilters: function(filters)

    对于默认实现,请查看 src/data/proxy/Server.js。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-16
    • 2011-07-15
    • 2011-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-24
    相关资源
    最近更新 更多