Extjs 网格面板中的持久化过滤器

Extjs 网格面板中的持久化过滤器,extjs,Extjs,我想在页面刷新时保留应用于gridpanel的过滤器。你能指导我做这件事吗 谢谢 下面是将筛选器数据发送到webservice的代码 Ext.extend(Ext.ux.AspWebServiceProxy, Ext.data.DataProxy, { load: function(params, reader, callback, scope, arg) { var userContext = { ca

我想在页面刷新时保留应用于gridpanel的过滤器。你能指导我做这件事吗

谢谢


下面是将筛选器数据发送到webservice的代码

 Ext.extend(Ext.ux.AspWebServiceProxy, Ext.data.DataProxy,       
 {
  load: function(params, reader, callback, scope, arg) {                 
  var userContext = {
               callback: callback,                   
               reader: reader,
               arg: arg,
               scope: scope
           };

  var proxyWrapper = this;

           //debugger;
           //Handles the response we get back from the web service call
           var webServiceCallback = function(response, context, methodName) {
               proxyWrapper.loadResponse(response, userContext, methodName);
           }

           var serviceParams = [];
           var filters = {};
           //Convert the params into an array of values so that they can be used in the call (note assumes that the properties on the object are in the correct order)
           for (var property in params) {
               if (property.indexOf("filter[") == 0) {
                   filters[property] = params[property];
               }
               else {
                   serviceParams.push(params[property]);
               }
               //console.log("Property: ", property, "Value: ", params[property]);
           }
           serviceParams.push(filters);

           //Add the webservice callback handlers
           serviceParams.push(webServiceCallback);
           serviceParams.push(this.handleErrorResponse);

           //Make the actual ASP.Net web service call
           this.webServiceProxyMethod.apply(this.webServiceProxy, serviceParams);
       },

       handleErrorResponse: function(response, userContext, methodName) {
           window.location.reload();
           //                               Ext.MessageBox.show({
           //                                       title: 'Error',
           //                                       msg: response.get_message(),
           //                                       buttons: Ext.MessageBox.OK,
           //                                       icon: Ext.MessageBox.ERROR
           //                                   });
           //alert("Error while calling method: " + methodName + "n" + response.get_message());
       },

       loadResponse: function(response, userContext, methodName) {
           var result = userContext.reader.readRecords(response);
           userContext.callback.call(userContext.scope, result, userContext.arg, true);
       }

   });

全局打开Ext JS状态管理器(在其中设置
Ext.BLANK\u IMAGE\u URL

用户对某些组件的更改现在将存储在cookie中,该cookie将在请求之间保持。如果需要存储其他自定义数据,可以使用
Ext.state.Manager.set
Ext.state.Manager.get
。状态可在单个组件上配置


Saki有一个。

要在网格上持久化过滤器,您可以使用cookies,在这里您可以找到一些帮助:

proxy: new Ext.data.HttpProxy({
        url: (local ? url.local : url.remote),
        method: 'GET',
        listeners:{
            beforeload : function(dataproxy,param) {
                if(param.searchConditions != undefined && param.searchConditions != '[]') {                     
                    Ext.util.Cookies.set('SearchConditions',param.searchConditions);
                }

            }
        }
    })
在上面的示例中,您可以发现我们正在Cookie中设置“searchConditions”JSONArray。现在让我们看看如何在加载网格时返回“searchCondition”

store.load({
            params:{
                start:0,
                limit: 50,
                searchConditions:JSON.parse(Ext.util.Cookies.get('SearchConditions'));
            }
        });

在这里,您只需要将“searchCondition”参数值作为存储在Cookie中的值传递。希望上面的示例有用。请评论以获取帮助。

Ext state Manager已打开。问题是网格面板显示已选中筛选器,并且其中的数据(文本框)也已保留,但问题是我在刷新时看不到已筛选的网格。你能帮我一下吗?恢复状态后,你可能需要手动重新加载存储。发布一些代码,这样我们可以复制它。嗨。。筛选器文本框的值存储在cookie中(在ext all debug.js中读取cookie)。但是当页面重新加载getfilterdata时,不会调用beforeload中的buildquery。当页面刷新时,gridfilters.js的beforeload函数没有被调用。你能帮我一下吗。
store.load({
            params:{
                start:0,
                limit: 50,
                searchConditions:JSON.parse(Ext.util.Cookies.get('SearchConditions'));
            }
        });