【问题标题】:Filtering grid with QueryReadStore使用 QueryReadStore 过滤网格
【发布时间】:2014-10-29 10:28:32
【问题描述】:

我有一个网格至极存储是一个 QueryReadStore。它工作正常,即使是虚拟滚动。 问题是过滤器,当我过滤时,它会生成一个像这样的奇怪 URL:

http://mydomain:8080/project=%3F&1=f&2=i&3=l&4=t&5=e&6=r&7=......

我想看起来像这样:

http://localhost:8080/project?filter={%22op%22:%22contains%22,%22data%22:[{%22op%22:%22string%22,%22data%22:%22username%22,%22isCol%22:true},{%22op%22:%22string%22,%22data%22:%22s%22,%22isCol%22:false}]}

这里是生成网格和过滤器的代码:

this.grid = new EnhancedGrid({ 
                store: null,
                structure: this.columns,         
                rowsPerPage: 20, 
                autoHeight: false, 
                plugins: {
                    filter: {
                        closeFilterbarButton: false,
                        isServerSide: true,
                        setupFilterQuery: dojo.hitch(this, function(commands, request){
                          if(commands.filter && commands.enable){
                              var gridStoreURL = this.grid.store.url;

                              if(gridStoreURL.indexOf("?") > -1) {
                                request.query = "&filter=" + JSON.stringify(commands.filter);
                              } else {
                                request.query = "?filter=" + JSON.stringify(commands.filter);
                              }
                          }else{
                          }
                        }),
                        ruleCount: 3,
                        itemsName: "logs",
                        disabledConditions: {anycolumn : this.disabledFilterAnyColumn}
                    }
                }
            }, this.idGridContainer);

我用这个函数创建了商店:

var store = dojox.data.QueryReadStore({
                url : this.urlBase + agentId,
                requestMethod:"get"
            });

            this.grid.setStore(store, null, null);

当我使用 JsonStore 创建商店时,过滤器可以正常工作,但这样就不行了。

提前谢谢你

【问题讨论】:

    标签: dojo dojox.grid.datagrid


    【解决方案1】:

    您似乎试图将商店查询设置为字符串,但 IIRC QueryReadStore 只希望查询作为对象传递,而不是 JsonRestStore 可以接受它。

    尝试这样的事情,首先,看看它是否能让你走得更远:

    request.query = { filter: JSON.stringify(commands.filter) }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-14
      • 1970-01-01
      相关资源
      最近更新 更多