如何在WebApi的Angular6 Scheduler中的Syncfusion中填充数据?

时间:2019-04-13 10:11:14

标签: angular6 scheduler syncfusion appointment

我正在使用调度程序在Angular6应用中设置约会。它适用于静态数据,但不能与Web Api调用绑定任何数据吗?

它可以与他们https://js.syncfusion.com/demos/ejservices/api/Schedule/LoadData提供的远程Api一起使用 并使用component.ts中的静态数据,但不使用我的本地Web API

我的Component.ts代码如下:-

@Component({
  selector: 'app-scheduler',
  templateUrl: './scheduler.component.html',
  styleUrls: ['./scheduler.component.css'],
  providers: [DayService, WeekService, MonthService],
})
export class SchedulerComponent implements OnInit {
  scheduler: any = {
    _id: "",
    id: "",
    Subject: "",
    StartTime: "",
    EndTime: "",
    StartTimezone: "",
    EndTimezone: "",
    Location: "",
    Description: "",
    IsAllDay: false,
    Recurrence: "",
    RecurrenceRule: "",
    Frequency: "",
    Interval: "",
    Count: "",
    IsReadonly: false,
    IsBlock: false,
    Untill: "",
    ByDay: "",
    BYMonthDay: "",
    BYMonth: "",
    BYSetPOS: ""
  }
  //public dataManager: any;
  public query;
  public ajax: any;

  actionModel: any;
  ds: any;
  public currentView: View = 'Month';
  public selectedDate: Date = new Date();

  private dataManager: DataManager = new DataManager({
    url: 'https://localhost:44369/api/Scheduler/getcalls',

    adaptor: new WebApiAdaptor,
    crossDomain: true
  });

  public eventSettings: EventSettingsModel = { dataSource: this.dataManager };



  constructor(
    protected service: SchedulerService, protected callService: CallService, protected meetingService: MeetingService,
    protected taskService: TaskService,  protected commentService: CommentService
  )
  {
    this.UpdateScheduler();
  }

  ngOnInit() {
    this.ds = [];
  }
  async UpdateScheduler() {
    debugger
    await this.service.getSchedulerData<any>()
      .subscribe(data => {
        data.map((x) => {
          this.ds.push({
            Id: x.id,
            Subject: x.subject,
            StartTime: new Date(x.startTime).toISOString().slice(0, -1),
            EndTime: new Date(x.endTime).toISOString().slice(0, -1),
            IsAllDay: x.allDay,
            Recurrence: true,
            RecurrenceID: x.Id,
            RecurrenceRule: 'FREQ=DAILY;INTERVAL=1;COUNT=5',
            Location: x.location,
            Description: x.description,
            StartTimezone: x.startTimezone,
            EndTimezone: x.EndTimezone,
          })
          console.log("ds1", this.ds);
          this.eventSettings.dataSource = this.ds;
          console.log("finalDataSource",this.eventSettings.dataSource);
        });
      }, error => {
        console.log("error1", error);
      }, () => { });
    //this.service.getSchedulerData();
   // this.eventSettings.dataSource = this.ds;
  }



  fnSchedulerModel(): any {
    return {
      _id: "",
      Subject: "",
      Location: "",
      ResponsiblePerson: "",
      Priority: "",
      Types: "",
      CreatedBy: "",
      UpdatedBy: "",
      CreatedDate: "",
      UpdatedDate: "",
      EventStartDate: "",
      EventEndDate: "",
      ReminderNotification: "",
      Completed: false,
      Description: "",
      RepeatTask: 0,
      Interval: "",
      RepeatAfter: "",
      Untill: "",
      UntillDate: "",
      UntillCompile: "",
      RemindUsing: "",
      RemindTo: "",
      RepeatEvery: "",
      RepeatOnWeekDay: "",
      RepeatOnDay: "",
      WillRepeat: "",
      WillRepeatWeekDay: "",
      RepeatOnMonth: ""
    }
  }

}

我正在调用的API是:-

WebApiCode :-

[HttpGet("GetCalls")]
        public List<DefaultSchedule> GetCalls(String CurrentDate, String CurrentView, String CurrentAction)
        {
            IEnumerable<Calls> model = _callRepository.GetAllCalls();
            List<DefaultSchedule> schedulerModelList = new List<DefaultSchedule>();
            int Id = 0;
            foreach (var call in model.ToList())
            {

                DefaultSchedule schedulerModel = new DefaultSchedule();
                schedulerModel.Id = 100;
                schedulerModel.AllDay = call.IsAllDay;
                schedulerModel.Description = call.Description;
                schedulerModel.StartTime = DateTime.Today;
                schedulerModel.StartTimeZone = call.StartTimeZone;
                schedulerModel.EndTime = DateTime.Today.AddDays(1);
                schedulerModel.Priority = true;
                schedulerModel.Subject = "CJECL";
                schedulerModel.Owner = 1;
                schedulerModelList.Add(schedulerModel);
                break;
            }
            return schedulerModelList;

        }

它在静态数据和此Web Api上都可以正常使用 https://js.syncfusion.com/demos/ejservices/api/Schedule/LoadData,当我在组件本身中提供数据但必须绑定WebApi中的数据时不工作。请帮忙。

我的要求是将远程数据绑定到调度程序。下面提供了演示,请看一下:-

https://help.syncfusion.com/angular/schedule/data-binding#binding-remote-data-service

1 个答案:

答案 0 :(得分:0)

Syncfusion的问候。

在Schedule中,批处理操作将无法在WebApi适配器上正常工作,对于相同的情况,我们已经记录了以下功能请求,该请求将在我们的任何后续发行版中实现。 https://www.syncfusion.com/feedback/2373/batch-handler-support-for-asp-net-core-while-using-webapi-adaptor

关于, 卡尔提