2017-09-27 34 views
1

往事,我使用full calendarAngular 2;如何隐藏/禁用fullcalendar

this.calendarOptions = { 
      height: '1000', 
      fixedWeekCount: false, 
      header: 
      { 
       left: 'prev,next,today', 
       center: 'title', 
       right: 'month,listYear', 
      }, 
      defaultDate: new Date(), 
      editable: true, 
      timeFormat: 'hh:mm A', 
      eventLimit: true, 


      events: (start, end, title, callback) => { 
       this.calenderservice.getExamCandidateById(this.value) 
        .subscribe(response => { 
         callback(response), 
          this.modalData = response.Items 
         this.myCalendar.fullCalendar('renderEvents', this.modalData) 
         console.log(this.modalData); 
         console.log(response); 
        }); 
      }, 

响应

Items:{ 
    ExamName:null 
    ExamSiteId:334 
    Id:85 
    LastUpdateDateTime:"0001-01-01T00:00:00" 
    PostalCode:"33172" 
    PptSeats:null 
    SeatCount:0 
    SiteName:"UF" 
    State:"FL" 
    end:"2017-09-27T10:30:00" 
    isCbt:"1" 
    isPpt:null 
    start:"2017-09-27T10:30:00" 
    title:"7 available" 
} 

从上面的代码我得到的所有启动和响应结束日期,并显示在事件日历

我想隐藏过去的事件,我如何隐藏包含当前日期在fullcalendar中的过去开始和结束日期的事件。

请帮帮我。

+0

也许不会从服务器首先返回它们?如果需要,你可以发送一个标志变量给服务器,以表明你不希望它在当前日期之前给你提供事件。目前,你甚至不会发送fullCalendar给你的开始/结束日期,所以我猜你甚至在fullCalendar不显示它们时也毫无意义地返回你的事件。 – ADyson

回答

0

您应该在将值传递到完整日历之前应用过滤器。像这样:

events: (start, end, title, callback) => { 
      this.calenderservice.getExamCandidateById(this.value) 
       .subscribe(response => { 
        callback(response), 
        var date = new Date(); //Today's date 
        this.modalData = response.Items.filter(item => item.StartDate > date || item.EndDate > date ); //only select items whose start or end date are after today's date. 
        this.myCalendar.fullCalendar('renderEvents', this.modalData) 
        console.log(this.modalData); 
        console.log(response); 
       }); 
+0

谢谢,'this.modalData = response.Items.filter(items => items.start> date || items.end> date);'我添加了,但是获得了modalData空数组, –

+0

可以吗'console.log (回应);'并在问题中加入。 –

+0

我对我的问题添加了回复。 –