문제

I have a Dojo EnhancedGrid with a JsonRest object wrapped in an ObjectStore. I want to send my filter criteria to the server.

My code to do this is almost exactly:

var myStore = new JsonRest({target:"data.jsp"});
var grid = new dojox.grid.EnhancedGrid({
  store: dataStore = new ObjectStore({objectStore: myStore}),
  id:"grid",
  query: { fileId: "*" },
  structure:"mystructure",
  plugins:{
    filter: {
      isServerSide: true,
      setupFilterQuery: setupFilter
    }
  }
});
var setupFilter = function(commands, request){
  if(commands.filter && commands.enable){
    request.query.filter = JSON.stringify(commands.filter);
  }
};

The problem is that commands.filter does not seem to hold valid date objects. Looking at it in Firefox's code debugger, it appears to hold numbers (memory addresses?) where dates should be.

An example result of JSON.stringify(commands.filter) on a date range query is :

{"op":"all","data":[{"op":"largerEqual","data":[{"op":"date","data":"uploadDate","isCol":true},{"op":"date","data":1382706000000,"isCol":false}]},{"op":"lessEqual","data":[{"op":"date","data":"uploadDate","isCol":true},{"op":"date","data":1381150800000,"isCol":false}]}]}

How can I include valid dates in the filter criteria?

도움이 되었습니까?

해결책

The number values are most likely the date in milliseconds since 1970/01/01

For example...

var a = new Date(1382706000000);

Now if you check what a is in the debugger or by logging it out, you should see it is a date object.

I logged out: Fri Oct 25 2013 14:00:00 GMT+0100 (GMT Daylight Time)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top