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. Image for the cookie policy date
close icon

Exception: this.parent.activeView is undefined

Hello!
I'm trying to reload events dynamically using subscription to RxJS subject but sometimes get the following exception on page load:

ERROR TypeError: "this.parent.activeView is undefined"
    getQuery ej2-schedule.es2015.js:4691
    addEvent ej2-schedule.es2015.js:4755
    addEvent ej2-schedule.es2015.js:11884
    ngAfterViewInit crews-scheduler.component.ts:80

It seems Schedule instance is not always fully instantiated inside AfterViewInit of the parent component.
Do you provide any event that I can catch and start to load scheduler events?
Here is the part of my component:

@ViewChild('scheduleObj', { static: true })
public scheduleObj: SyncfusionScheduleComponent;

ngAfterViewInit() {
        this.loadedEvents$.subscribe(events => {
// getEvents() fails sometimes here too, but this is not critical since I can skip removing if it is the first load
            if (this.scheduleObj.eventBase) {
                const existingEvents = this.scheduleObj.getEvents() as any[];
                if (existingEvents && existingEvents.length > 0)
                    this.scheduleObj.deleteEvent(existingEvents);
            }
            if (events.length > 0)
                this.scheduleObj.addEvent(events.map(clone)); // here I get the exception!
        });
    }

3 Replies

VD Vinitha Devi Murugan Syncfusion Team September 11, 2019 01:41 PM UTC

Hi Artem, 
 
Syncfusion Greetings. 
 
We have checked your shared scenario but scheduler working fine at our end. We suspect that your requirement is to update the scheduler event on ngAfterViewInit we have prepared the below sample for the same kindly refer it. 
 

ngAfterViewInit() { 
    const studentsObservable = this.scheduleService.getSchedule(); 
    studentsObservable.subscribe((scheduleData: Schedule[]) => { 
      this.scheduleObj.eventSettings.dataSource = scheduleData; 
    }); 
  } 
 
Kindly try with the above sample and let us know if you need any further assistance on this.  
 
Regards, 
M.Vinitha devi 
 



UN Unknown Syncfusion Team September 13, 2019 08:15 AM UTC

Thank you! It seems it works well.


KK Karthigeyan Krishnamurthi Syncfusion Team September 16, 2019 04:34 AM UTC

 


Loader.
Live Chat Icon For mobile
Up arrow icon