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

3 posts, 0 answers
  1. AndersSpetz
    AndersSpetz avatar
    8 posts
    Member since:
    Apr 2016

    Posted 26 Apr 2017 Link to this post

    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. AndersSpetz
    AndersSpetz avatar
    8 posts
    Member since:
    Apr 2016

    Posted 27 Apr 2017 in reply to AndersSpetz Link to this post

    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.

  3. Plamen
    Admin
    Plamen avatar
    3056 posts

    Posted 28 Apr 2017 Link to this post

    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.
Back to Top