如何将dojo EnhanceGrid的过滤器定义转移到服务器端 [英] How can filter definition of dojo EnhanceGrid be transfered to server-side

查看:170
本文介绍了如何将dojo EnhanceGrid的过滤器定义转移到服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用dojox.grid.EnhancedGrid的过滤器插件。其介绍在 http ://dojotoolkit.org/reference-guide/dojox/grid/EnhancedGrid/plugins/Filter.html#dojox-grid-enhancedgrid-plugins-filter



要实现服务器端过滤器,它说:



默认情况下,服务器端被假定为无状态(REST风格)这种情况下,您应该将过滤器定义与存储的提取请求一起发送到服务器端,您可以通过在调用store.fetch之前每次修改请求对象来执行此操作。



它给出了一些示例代码的一部分:

  var grid = new dojox.grid。 EnhancedGrid({
id:grid,
store:mystore,
structure:mystructure,
plugins:{
filter:{
isServerSide:true,
setupFilterQuery:setupFilter
}
}
});
var setupFilter = function(commands,request){
//这里的命令对象与状态服务器的POSTed命令对象相同,请参见下文。
if(commands.filter&& commands.enable){
//某些过滤器被定义和有效。您可以在此处修改请求对象。
} else {
//没有过滤器有效。
}
};

从这个例子中,我仍然不知道如何将过滤器定义传输到服务器端。 commands.filter是像树一样的json对象。如何通过url参数传递到服务器端。有人可以给我一些示例代码?



最好的问候
ZY

解决方案

您可以使用dojo.toJson序列化整个过滤器定义并在服务器端评估它

eg

  request.query.filter = dojo.toJson(commands.filter); 

敬意


I'm using filter plugin of dojox.grid.EnhancedGrid. Its introduction is at http://dojotoolkit.org/reference-guide/dojox/grid/EnhancedGrid/plugins/Filter.html#dojox-grid-enhancedgrid-plugins-filter.

And to implement the server-side filter, it says:

"By default, the server side is assumed to be stateless (REST style). In this case, you should send the filter definition to server side along with the fetch request of the store. You can do this by modifying the request object every time before store.fetch is called."

And it gives some part of example code:

var grid = new dojox.grid.EnhancedGrid({
  id:"grid",
  store:"mystore",
  structure:"mystructure",
  plugins:{
    filter: {
      isServerSide: true,
      setupFilterQuery: setupFilter
    }
  }
});
var setupFilter = function(commands, request){
  //the commands object here is the same as the POSTed commands object for stateful server, see below.
  if(commands.filter && commands.enable){
    //some filter is defined and valid. You can modify the request object here.
  }else{
    //no filter is valid.
  }
};

From this example , I still don't know how to transfer the filter definition to the sever side. commands.filter is a json object like a tree. How can it be passed to server side through url parameters. Can someone give me some example codes?

Best Regards ZY

解决方案

you may use dojo.toJson to serialize the whole filter-defintion and evaluate it on the server-side
e.g.

request.query.filter=dojo.toJson(commands.filter);  

regards

这篇关于如何将dojo EnhanceGrid的过滤器定义转移到服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆