dojoEnhanceGrid的过滤器定义如何转移到服务器端

发布于 2024-11-08 08:30:07 字数 1152 浏览 0 评论 0原文

我正在使用 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){
  //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.
  }
};

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

此致 ZY

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凉风有信 2024-11-15 08:31:38

您可以使用 dojo.toJson 序列化整个过滤器定义并在服务器端对其进行评估
例如

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

问候

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文