Cannot read property 'isTimelineView' of undefined

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




The scheduler is rendering fine, everything else is working as expected.
We are using the TimelineDay view.

Do you have any idea how we can prevent this error? Thanks in advance

7 Replies

RV Ravikumar Venkatesan Syncfusion Team August 12, 2022 11:26 AM UTC

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.


  • Share the entire code snippet of the Schedule or
  • Reproduce the problem in our shared sample or
  • Share a simple issue reproducing sample if possible.


Sample: https://stackblitz.com/edit/ej2-js-schedule-timeline-views-sample?file=index.js


Regards,

Ravikumar Venkatesan



JL joseph livingstone replied to Ravikumar Venkatesan August 14, 2022 07:49 AM UTC

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



RM Ruksar Moosa Sait Syncfusion Team August 16, 2022 04:03 PM UTC

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:


Graphical user interface, application, table, Excel

Description automatically generated


Kindly try the attached sample and let us know if this meets your requirement.


Regards,

Ruksar Moosa Sait


Attachment: MVC_applicationNavigatetospecificdate_13e2b1d8.zip


JL joseph livingstone replied to Ruksar Moosa Sait August 17, 2022 05:27 AM UTC

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



RM Ruksar Moosa Sait Syncfusion Team August 18, 2022 02:22 PM UTC

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


Attachment: MVCNavigatespecificdate_7ec16813.zip


JL joseph livingstone replied to Ruksar Moosa Sait August 18, 2022 08:58 PM UTC

This works perfectly! No more errors. Thank you!



RV Ravikumar Venkatesan Syncfusion Team August 19, 2022 07:33 AM UTC

Hi Joseph,


Thanks for the update.


We are happy that our solution helped you to resolve your reported problem.


Regards,

Ravikumar Venkatesan


Loader.
Up arrow icon