After setting the selectedDate property like so
function SetCurDate(_date) {
let _start_date = new Date(_date);
scheduleObj.selectedDate = _start_date;
}
I get the following error
Hi Joseph,
Greetings from Syncfusion support.
We have validated your query “Cannot read property 'isTimelineView' of undefined” at our end by preparing a sample based on your shared details. But, we are unable to reproduce the problem on our end. Based on the call stack we suspect that the current active view module of the Schedule seems to be undefined. We need additional details to validate the problem at our end. Can you kindly share the below details it will help us to validate and provide the solution for your problem earlier.
Sample: https://stackblitz.com/edit/ej2-js-schedule-timeline-views-sample?file=index.js
Regards,
Ravikumar Venkatesan
Greetings,
Ultimately what I want to achieve is the ability to navigate to a specific date on the scheduler via properties in a query string. For eg. https://Website/Schedule?date=20220812 . Now what I have done is create an action that accepts this parameter and then passes it to the javascript function SetCurDate.
It is at this point that the error is thrown. Hopefully with this information you will be able to figure out what i'm doing wrong.
Or, if you have any example of how to navigate to a specific date via a URL/QueryString the please share.
Thanks in advance
Hi Joseph,
We have checked on your shared codes and suggest you to set SelectedDate from the ViewBag in the Created event of the scheduler like the below code to navigate to specific date.
[Index.cshtml]
|
<script type="text/javascript"> function OnCreate() { let ScheduleObj = document.getElementById("schedule").ej2_instances[0]; ScheduleObj.selectedDate = @Html.Raw(Json.Encode(ViewBag.SelectedDate)); } </script> |
[HomeController.cs]
|
public ActionResult Index(int id = 0) { try { string new_date = ""; if (id > 0) { new_date = id.ToString().Substring(0, 4) + "-" + id.ToString().Substring(4, 2) + "-" + id.ToString().Substring(6, 2) + " " + DateTime.Now.ToString("hh:mm tt"); ViewBag.SelectedDate = new_date; } else { id = 20220112; new_date = id.ToString().Substring(0, 4) + "-" + id.ToString().Substring(4, 2) + "-" + id.ToString().Substring(6, 2) + " " + DateTime.Now.ToString("hh:mm tt"); ViewBag.SelectedDate = new_date; } } catch (Exception ex) { ex.Log(); } return View(); } |
Output:
Kindly try the attached sample and let us know if this meets your requirement.
Regards,
Ruksar Moosa Sait
Unfortunately your suggestion has not solved the problem as I'm still getting the javascript error. The error speaks to the isTimelineView being undefined even though in my definition of the object I set the currentView property to TimelineDay.
I also noticed in your example that you are not using a TimeLine. Not sure if this makes a difference.
I look forward to your quuick response
Regards
Hi Joseph,
We have prepared a sample with your shared code and suggest you directly set the date value which the Schedule needs to be navigated on the initial rendering from the ViewBag to the selectedDate property of the schedule like the below code to overcome the reported problem.
[Index.cshtml]
|
selectedDate: new Date (@Html.Raw(Json.Encode(ViewBag.SelectedDate)))
|
Kindly try the attached sample and let us know if this meets your requirement.
Regards,
Ruksar Moosa Sait
This works perfectly! No more errors. Thank you!
Hi Joseph,
Thanks for the update.
We are happy that our solution helped you to resolve your reported problem.
Regards,
Ravikumar Venkatesan