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

Get dataSource onInit. Get empty data source

Hello,

I am trying to set data source onInit but I am getting no data in my schedule. I am trying to do it from example: https://stackblitz.com/edit/angular-e6agtu-d4jsxx?file=app.component.ts

Also in my case I am using TimeLine grouping functionality (like in this example: https://ej2.syncfusion.com/angular/demos/#/material/schedule/timeline-resource-grouping). I am using fro that remote data.

When I am trying to set data onInit as empty array (or do not set dataSource at all) I am getting error:


My code looks something like this:

And onInit I am settings all data sources as empty array like:



3 Replies

NR Nevitha Ravi Syncfusion Team May 21, 2019 07:34 AM UTC

Dear customer, 

Greetings from Syncfusion Support. 

We have checked your sample in which ngOnInit is misspelled which results in empty scheduler. We have modified the sample which can be viewed from the following link. 

import { Component, OnInit } from '@angular/core'; 
import { EventSettingsModel, View, DayService, WeekService, WorkWeekService, MonthService, AgendaService } 
  from '@syncfusion/ej2-angular-schedule'; 
import { DataManager, WebApiAdaptor } from '@syncfusion/ej2-data'; 
 
@Component({ 
  selector: 'app-root', 
  templateUrl: 'app.component.html', 
  providers: [DayService, WeekService, WorkWeekService, MonthService, AgendaService] 
}) 
export class AppComponent implements OnInit { 
  public selectedDate: Date = new Date(2017, 5, 5); 
  public currentView: View = 'Week'; 
  public readonly: boolean = true; 
  private dataManger: DataManager = new DataManager({ 
    url: 'https://js.syncfusion.com/demos/ejservices/api/Schedule/LoadData', 
    adaptor: new WebApiAdaptor, 
    crossDomain: true 
  }); 
  // public eventSettings: EventSettingsModel = { dataSource: this.dataManger }; 
  public eventSettings: EventSettingsModel = {}; 
 
  ngOnInit() { 
    this.eventSettings.dataSource = this.dataManger; 
  } 
 
} 


Regards, 
Nevitha 



UN Unknown Syncfusion Team May 24, 2019 05:24 AM UTC

Yes, sorry, it was my mistake. It solves the problem with example. But still this does not solve the other problem where I am getting error which was also described in my problem.


KK Karthigeyan Krishnamurthi Syncfusion Team May 27, 2019 11:40 AM UTC

Dear Customer, 
 
Thanks for the update. 
 
We suspect that empty data source is assigned to resource (projectDataSource and categoryDataSource) without giving empty data source to group property which could be the cause. Kindly use the below code example and if the issue persists, try to reproduce the error in a sample and revert. 
 
ngOnInit() { 
    this.eventSettings.dataSource = []; 
    this.projectDataSource = []; 
    this.categoryDataSource = []; 
    this.group.resources = []; 
  } 
 
Regards, 
Karthi 


Loader.
Live Chat Icon For mobile
Up arrow icon