0

我正在使用“dojo/data/ItemFileWriteStore”外观:{“identifier”:“id”、“items”:[{“id”:“3”、“date_start”:“02/11/2012”、“date_end” ":"02/11/2012","time_end":"11:00:00","time_start":"09:00:00","type":"visit","title":"一些标题一","week_day":"5","start_hour":"9","start_minute":"0","duration":"120","day_long":"false"}, {"id":"4 ","date_start":"23/10/2012","date_end":"05/11/2012","time_end":"12:15:00","time_start":"10:15:00", “类型”:”visit","title":"Some Title Two","week_day":"2","start_hour":"10","start_minute":"15","duration":"120","day_long":"真的 ”} ]}

然后我通过以下代码将 ItemFileWriteStore 解析为日历存储:

var cal_data = [];

var gotList = function(items, request){
    dojo.forEach(items, function(item){
      d_start = item.date_start[0].split('/');
      d_end = item.date_end[0].split('/');

      var dStart = new Date(parseInt(d_start[2]), (parseInt(d_start[1]) - 1), parseInt(d_start[0]), parseInt(item.start_hour[0]), parseInt(item.start_minute[0]), 0, 0);
      var dEnd = new Date(parseInt(d_end[2]), (parseInt(d_end[1]) - 1), parseInt(d_end[0]), 0, 0, 0, 0);

      var o = {
         id: item.id[0],
         summary: item.title[0],
         startTime:dStart,
         endTime:dEnd,
         calendar: item.type[0],
         allDay:(item.day_long[0] == "true" ? true : false)
      };

      //o.startTime=calendar.dateModule.add(o.startTime, "day", 1);
      o.startTime.setHours(parseInt(item.start_hour[0]));
      o.startTime.setMinutes(parseInt(item.start_minute[0]));
      o.endTime = calendar.dateModule.add(o.startTime, "minute", parseInt(item.duration[0]));

      console.log(o);

      cal_data.push(o);
    });
}

var gotError = function(error, request){
    console.log("The request to the store failed. ",  error);
}

TaskStore.fetch({
    onComplete: gotList,
    onError: gotError
});

calendar.set("store", new Observable(new Memory({data: cal_data})));

上述代码的控制台日志显示: Object allDay: false calendar: "visit" endTime: Fri Nov 02 11:00:00 GMT+0200 (Jerusalem Standard Time) id: "3" startTime: Fri Nov 02 2012 09: 00:00 GMT+0200(耶路撒冷标准时间)摘要:“Some Title One” 原型:对象仪表板:124

对象 allDay: true calendar: "visit" endTime: Tue Oct 23 2012 12:15:00 GMT+0200 (Jerusalem Standard Time) id: "4" startTime: Tue Oct 23 2012 10:15:00 GMT+0200 (Jerusalem Standard Time)时间)摘要:“一些标题二” 原型:对象仪表板:124

一切似乎都很好,但日历仍然没有显示项目,为什么?

4

1 回答 1

0

你应该打电话给

calendar.set("store", new Observable(new Memory({data: cal_data})));

在 goList 方法结束时它应该解决问题吗?

于 2012-10-29T11:01:09.790 回答