How can filter definition of dojo EnhanceGrid be transfered to server-side

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 05:13:46

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/6069246/how-can-filter-definition-of-dojo-enhancegrid-be-transfered-to-server-side

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!