How can filter definition of dojo EnhanceGrid be t

2019-08-07 06:01发布

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

标签: filter dojo grid
1条回答
姐就是有狂的资本
2楼-- · 2019-08-07 06:42

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

查看更多
登录 后发表回答