We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get schedule start and end date on page load

Thread ID:

Created:

Updated:

Platform:

Replies:

149177 Nov 18,2019 04:23 AM UTC Dec 2,2019 07:32 AM UTC Angular - EJ 2 3
loading
Tags: Schedule
jose lara
Asked On November 18, 2019 04:23 AM UTC

Hi, at the time the scheduler initially loads, how can I get the current view start and end date? I tried this.scheduleObj.getCurrentViewDates() but it is empty.

Vinitha Devi Murugan [Syncfusion]
Replied On November 18, 2019 07:17 AM UTC

Hi Jose, 
 
Syncfusion Greetings. 
 
We achieved your requirement by making use of created event of the scheduler. Please refer below sample. 
 
 
  onCreated(): void { 
    // To get current view date we used getCurrentViewDates public method 
    let currentViewDates: Date[] = this.scheduleObj.getCurrentViewDates() as Date[]; 
    let startDate: Date = currentViewDates[0] as Date; 
    let endDate: Date = currentViewDates[currentViewDates.length - 1] as Date; 
    console.log(startDate); 
    console.log(endDate); 
  } 
 
Regards, 
M.Vinitha devi 


jose lara
Replied On November 30, 2019 09:32 PM UTC

Thx. This works inside the onCreated() method. But, when I use the same logic inside of onNavigating() method, the dates are one week behind. How can I get the current dates in other events as well? 

Vinitha Devi Murugan [Syncfusion]
Replied On December 2, 2019 07:32 AM UTC

Hi Jose, 
 
Thanks for your update. 
 
You can get the start and end date of current date range by making use of actionComplete event with args.requestType viewNavigate and dateNavigate. For the same we have prepared the below sample, kindly refer it. 
 

//To get the start and end dates of current view and current Date range 
  onActionComplete(args): void { 
    if ( args.requestType === "viewNavigate" || args.requestType === "dateNavigate") { 
      var currentViewDates = this.scheduleObj.getCurrentViewDates(); 
      var startDate = currentViewDates[0]; 
      var endDate = currentViewDates[currentViewDates.length - 1]; 
      console.log(startDate); 
      console.log(endDate); 
    } 
  } 
 
Note: Naviagating event triggers before the date or view navigation takes place on scheduler. 
 
Regards, 
M.Vinitha devi 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon