2015-05-05 30 views
2

我試圖在API上創建一個項目,並用新的'ScheduleID'返回一個值,當我做了一個跟蹤時,API在新返回一個新的ScheduleID創建的對象,但ScheduleID永遠不會保存在dataSource中。有人知道爲什麼Kendo調度器,新創建的對象ID不保存在數據源中

vm.schedulerOptions = { 
    date: new Date(classStartDate.getUTCFullYear(), classStartDate.getUTCMonth(), classStartDate.getUTCDate(), 0, 0, 0), 
    height: 600, 
    views: [ 
    "day", 
    {type: "week", selected: true}, 
    ], 

    dataSource: { 
    transport: { 
     read: function (options) { 
     if ($stateParams.classId) { 
      scheduleDf.getScheduleByClassId($stateParams.classId).success(function (result) { 
      options.success(result); 
      }).error(function (err) { 
      options.error(err); 
      }) 
     } else if ($stateParams.sectionId) { 
      scheduleDf.getScheduleBySectionId($stateParams.sectionId).success(function (result) { 
      options.success(result); 
      }).error(function (err) { 
      options.error(err); 
      }) 
     } 
     }, 
     create: function (options) { 
     options.data.ClassId = classInfor.data[0].ClassID; 
     options.data.AtLocationId = vm.locationCb.dataItem().LocationID; 
     options.data.ConfirmationNumber = vm.ConfirmationNumber; 
     scheduleDf.createSchedule(options.data).success(function (result) { 
      //vm.grid.dataSource.read(); 
      options.success(result); 
     }).error(function (err) { 
      options.error(err); 
     }) 
     }, 
     update: function (options) { 
     if (!fromMovingBar) { 
      options.data.AtLocationId = vm.locationCb.dataItem().LocationID; 
      fromMovingBar = false; 
     } 
     scheduleDf.updateSchedule(options.data).success(function (result) { 
      vm.grid.dataSource.read(); 
      options.success(result); 
     }).error(function (err) { 
      options.error(err); 
     }) 
     }, 
     destroy: function (options) { 
     scheduleDf.deleteSchedule(options.data.ScheduleID).success(function (result) { 
      vm.grid.dataSource.read(); 
      options.success(); 
     }).error(function (err) { 
      options.error(err); 
     }) 
     } 
    }, 
    schema: { 

     model: { 
     id: "ScheduleID", 

     fields: { 

      start: {type: "date", from: "FromTime"}, 
      end: {type: "date", from: "ToTime"} 
     } 
     } 
    } 
    }, 
    editable: { 
    template: '<div ng-include="' + "'/schedule/_schedule_editor.html'" + '"></div>', 
    create: false 
    }, 
    edit: function (e) { 
    e.container.data("kendoWindow").center(); 
    e.container.find(".k-edit-form-container").width("auto"); 
    e.container.data("kendoWindow").wrapper.css({width: 700}); 
    }, 
    moveEnd: function (e) { 
    fromMovingBar = true; 
    }, 
    resizeEnd: function (e) { 
    fromMovingBar = true; 
    }, 
    resources: [{ 
    field: 'SessionTypeID', 
    dataColorField: 'ColorCode', 
    dataValueField: 'SessionTypeID', 
    dataTextField: 'SessionTypeName', 
    dataSource: sessionTypes.data 
    }] 
}; 

回答

0

當前行爲的原因是來自服務器的響應格式與「讀取」請求的格式不同。你應該嘗試在數組內插入記錄。欲瞭解更多信息,你可以檢查這help article.

另外我注意到調度程序沒有設置時區選項。請注意,時區選項強烈建議設置爲 - 有關更多詳細信息,您可以檢查new Timezones help article

相關問題