Initializing to a Units View(Angular)

I want to initialize(default) the scheduler to a Units view, but when I do this:

scheduler.setCurrentView(null, view);

in either ngOnInit or ngAfterViewInit it throws an error. It does switch to the units view. Works fine for day, week or month with no error. The error:

Error: site view is not defined.
Please check parameters you pass to scheduler.init or scheduler.setCurrentView in your code and ensure you’ve imported appropriate extensions.
Related docs: Views Scheduler Docs

at e3.render_view_data (event.js:223:1)

Thanks,
Larry

Hello @Larry,

The described issue could have occurred if you didn’t enable the Units plugin, like follows:

scheduler.plugins({
    units: true
});

Kind regards,

Units are enabled. They work fine unless I try to set the Unit view as the default.

Larry

Hello @Larry,

Thank you for the clarification, if you want to initialize scheduler with some view(for example Units), you should use the init method, like follows:

scheduler.createUnitsView({
    name:"unit",

....
scheduler.init("scheduler_here",new Date(2020, 5, 29),"unit");

Demo:
https://snippet.dhtmlx.com/hynf43lz

You also should be able to set the units view after scheduler loading with the setCurrentView method, like follows:

scheduler.init("scheduler_here",new Date(2020, 5, 29),"week");


...

scheduler.setCurrentView(null, "unit"); 

But it’s suggested to pass Date as first parameter.

Here is a demo:
https://snippet.dhtmlx.com/2dctmw93

If it doesn’t work in your case, it’s hard to suppose what goes wrong in your case without more details, so could you please reproduce the issue in the following snippet:
https://snippet.dhtmlx.com/2dctmw93
(open the snippet => reproduce the issue => click the “Save” button => post here the new link)?

Or send me a simplified demo with all necessary files and run instructions, that I will be able to run on my side and check out what exactly goes wrong.

Kind regards,

Thanks, that worked
Larry