Help for setting startup date
rgry opened this issue · 4 comments
Hope you would help me with some sample code that can change the date that the calendar shows on startup.
I do understand your sample with custom buttons, but how do I do it in code.
I read some data and then I would like to choose the date I show in the calendar for the user to start with.
You would call BlazorScheduler. SetCurrentMonth(dateTime)
where dateTime is a DateTime with the specific date you want to show.
Sorry, can't get the calendar view to move.
In programs.cs I have
.AddSingleton<BlazorScheduler.Scheduler>()
In calenderviewpage
@Inject Scheduler scheduler
.
.
protected override void OnInitialized()
{
..
DateTime dt = DateTime.Now.AddMonths(-6);
scheduler.SetCurrentMonth(dt);
StateHasChanged();
}
You should not be creating a singleton of a component like you are doing. Remove that from your Program.cs
Then on your page add:
<Scheduler @ref="scheduler">
...
</Scheduler>
And in the @code
block add
private Scheduler scheduler;
protected override void OnInitialized()
{
..
DateTime dt = DateTime.Now.AddMonths(-6);
scheduler.SetCurrentMonth(dt);
}
Please take a look at Configuration.razor for more info on calling methods on the Scheduler.
Thank you again, looking at your example and Configuration.razor did help :-)