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

Individual independent Appointment colors

9 Answers 246 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
Roland asked on 30 Jul 2020, 05:34 PM

How do I influence the styling of appointments, and in particular the background color, without using a resource/groupby view or css?

I want to be able to decide runtime what the color should be.

9 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 30 Jul 2020, 05:42 PM

Hi Roland,

When Templates get implemented you will be able to add your own rendering at runtime: https://feedback.telerik.com/blazor/1457901-templates-for-appointments.

 

Regards,
Marin Bratanov
Progress Telerik

0
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 31 Jul 2020, 05:02 PM
My current workaround is introducing a <SchedulerResource> for the types of Appointments I want to have a distinct color.
This works because <SchedulerResource> changes nothing about the presentation other than the Appointment color.
It will backfire when proper Resource Views are implemented, but it'll do for now.
0
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 31 Aug 2020, 05:12 PM

No idea what changed, but I now always get an error when using:

<TelerikScheduler ...>
  <SchedulerViews>
    ...
  </SchedulerViews>
 
  <SchedulerResources>
    <SchedulerResource ... Data="@myList" ... ColorField="@nameof(SomeEntity.Color)"/>
  </SchedulerResources>
</TelerikScheduler>

 

myList is populated in OnInitializedAsync().

The error is:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Blazor.Components.Scheduler.ViewModels.SchedulerViewModelBase.GetResourceColors().

Any ideas?

0
Marin Bratanov
Telerik team
answered on 31 Aug 2020, 06:29 PM

Hi Roland,

Since this worked recently, I'd suggest reviewing the source control history of the scheduler settings, the data service and the resource model for changes that can cause issues. My best guess is that something in the names of the fields does not match between the resource tag settings and the actual model data - for example, missing values in the resource collection or them being in another field, or missing public getters.

If this does not help you move forward, please modify the sample from the docs to showcase the issues so I can have a look.

 

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 31 Aug 2020, 09:13 PM
In fact this has bothered me from the start, but at first only incidentally.
I assumed it was some sort of race condition, or I had picked the wrong Blazor event to populate my lists.

But I'll have a look at your demo and report back :).
0
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 01 Sep 2020, 11:40 AM

I looked at the online demo, and it has the exact same problem.

As soon as the data is retrieved in OnInitializedAsync() and you have to await the data loading you get the beforementioned exception. The demo only works because all data is loaded (synchronously, hardcoded) in the constructor.

0
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 01 Sep 2020, 02:11 PM
And as soon as I retrieve the appointments synchronously, the error goes away...

Also the demo documentation says that SchedulerResource.Field and .ValueField must be strings, but using Guid IDs works as well.
0
Accepted
Marin Bratanov
Telerik team
answered on 01 Sep 2020, 02:27 PM

Hi Roland,

Does initializing the collection help, like in the sample I am attaching below? It should, and I've added that to the docs (commit and changed article).

On another note, you may want to use the standard loading sign pattern from the default FetchData.razor page to only show the scheduler after all relevant data has arrived.

 

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
answered on 01 Sep 2020, 02:42 PM

Yes, your solution works as well. You don't need to retrieve the resource data synchronously.

As long as the resource list ("Managers" in the demo) is initialised with an empty list, you can than retrieve the resource asynchronously. Leaving the resource list null while awaiting the data causes the exception.

Tags
Scheduler
Asked by
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
Answers by
Marin Bratanov
Telerik team
Roland
Top achievements
Rank 3
Iron
Iron
Veteran
Share this question
or