This is a migrated thread and some comments may be shown as answers.

scheduler.view() defaults to undefined when using npm and webpack (angular-cli)

2 Answers 182 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
AndersSpetz
Top achievements
Rank 1
AndersSpetz asked on 26 Apr 2017, 07:20 PM

A really simple angular-cli project, the only thing changed after ng new is installing kendo-ui, @types/kendo-ui and @types/jquery and then adding jquery and kendo-ui to types in tsconfig-app.json

Then use this for the app.component.ts

import { Component, OnInit } from '@angular/core';
import * as $ from "jquery";
import '@progress/kendo-ui/js/kendo.scheduler';
@Component({
    selector: 'app-root',
    template: `<div id="scheduler"></div>`
})
export class AppComponent implements OnInit {
    public ngOnInit(): void {
        let scheduler = $("#scheduler").kendoScheduler({
            date: new Date("2013/6/13"),
            startTime: new Date("2013/6/13 07:00 AM"),
            views: [
                "day",
                { type: "workWeek", selected: true },
                "week",
                "month"
            ]
        }).data("kendoScheduler");
         
        console.log(scheduler.view()); //undefined
        scheduler.view("month");
        console.log(scheduler.view());
    }
}

 

The problem is that when not explicitly set, scheduler.view() is undefined, then when set, it works as expected.

I would expect it to be set to whatever the calendar has as selected view, and this is how it works when using the system.js version of kendo-ui, so something seems really fishy here since I would assume the codebase is the same between the system.js and npm(amd) versions.

I have not been able to completely rule out angular-cli here, since I cannot get the system.js version of kendo-ui to work in angular-cli, and I have not tried getting the npm version to work in a system.js based build system yet.

2 Answers, 1 is accepted

Sort by
0
AndersSpetz
Top achievements
Rank 1
answered on 27 Apr 2017, 10:46 AM

After som more examination, it turns out that the scheduler.view() will eventually have it's value, but not directly, so by waiting some time (check by setting a timeout, or actually waiting for "scheduler.view() != null" i a loop, it will eventually get its value.

So now the problem is rather that we would want some kind of promise or some way of knowing when the scheduler has finished initializing so we can start using the view() command.

0
Plamen
Telerik team
answered on 28 Apr 2017, 12:25 PM
Hi,

We have observed such behavior when using jQuery 3. In such case you can use the Scheduler initial dataBound event and get the view from there.  

Regards,
Plamen
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Scheduler
Asked by
AndersSpetz
Top achievements
Rank 1
Answers by
AndersSpetz
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or