dojoEnhanceGrid的过滤器定义如何转移到服务器端
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 dojo.toJson 序列化整个过滤器定义并在服务器端对其进行评估
例如
问候
you may use dojo.toJson to serialize the whole filter-defintion and evaluate it on the server-side
e.g.
regards