Help with resources

Hello.

I would like to see your way of providing multiple resources for scheduler.

Given that:

  • Main appointment object can be assigned to 2 optional resources
  • Appointment can have a 0 or 1 resources called 'Gate' assigned
  • Appointment can have 0 to N resources called 'Season' assigned to it
  • Appointment object has a 'int?' field called GateId for gate resource
  • It also has a 'string[]' field called SeasonIds for season resources
  • Other than those, there are only typical fields taken from your standard example scheduler
Gate object has an 'int' id and a name.
Season object only has a name (string) which is unique.

Given this information, how would you create a scheduler object that can use such resources, including grouping functionality?

4 Replies

HW Henryk Wisniewski October 7, 2021 12:18 PM UTC

Addition - to simplify the situation, lets even constrain ourselves to single type of resource for an appointment.

To do this, lets assume that there is an appointment, as mentioned in post above, but with only ONE possible resource (Season).

This Season resource has only it's name (string, unique) - this is it's database storage form, it doubles as ID.

Each appointment can have 0, 1 or more unique Seasons in it's 'SeasonsIds' property (string[]) - so AllowGroupEdit is set to true.

What would be a proper Syncfusion scheduler configuration for case like this?
How to properly set scheduler so it will display the resources, including one that contains appointments without season set (for now I just add a dummy season of none).




PN Praveenkumar Narasimhanaidu Syncfusion Team October 7, 2021 05:39 PM UTC

Hi Henryk, 

Greetings from Syncfusion support..! 

We have validated your requirements and prepared a sample according to that. The sample can be downloaded from the following link. 

<SfSchedule TValue="AppointmentData" Height="550px" @bind-SelectedDate="@CurrentDate"> 
    <ScheduleGroup Resources="@Resources"></ScheduleGroup> 
    <ScheduleResources> 
        <ScheduleResource TItem="ResourceData" TValue="string[]" DataSource="@SeasonsData" Field="SeasonId" Title="Season" Name="Seasons" TextField="Id" IdField="Id" ColorField="Color" AllowMultiple="true"></ScheduleResource> 
    </ScheduleResources> 
    <ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings> 
    <ScheduleViews> 
        <ScheduleView Option="View.Day"></ScheduleView> 
        <ScheduleView Option="View.Week"></ScheduleView> 
        <ScheduleView Option="View.WorkWeek"></ScheduleView> 
        <ScheduleView Option="View.Month"></ScheduleView> 
        <ScheduleView Option="View.Agenda"></ScheduleView> 
    </ScheduleViews> 
</SfSchedule> 
@code{ 
    DateTime CurrentDate = new DateTime(2020, 1, 31); 
    public string[] Resources { get; set; } = { "Seasons" }; 
    List<AppointmentData> DataSource = new List<AppointmentData> 
{ 
        new AppointmentData { Id = 1, Subject = "Meeting", StartTime = new DateTime(2020, 1, 31, 9, 30, 0) , EndTime = new DateTime(2020, 1, 31, 11, 0, 0), SeasonId = "Season1" } 
    }; 
    public List<ResourceData> SeasonsData { get; set; } = new List<ResourceData> 
{ 
        new ResourceData{ Id = "Season1", Color = "#ffaa00" }, 
        new ResourceData{ Id = "Season2", Color = "#f8a398" }, 
        new ResourceData{ Id = "Season3", Color = "#7499e1" } 
    }; 
    public class AppointmentData 
    { 
        public int Id { get; set; } 
        public string Subject { get; set; } 
        public string Location { get; set; } 
        public DateTime StartTime { get; set; } 
        public DateTime EndTime { get; set; } 
        public string Description { get; set; } 
        public bool IsAllDay { get; set; } 
        public string RecurrenceRule { get; set; } 
        public string RecurrenceException { get; set; } 
        public Nullable<int> RecurrenceID { get; set; } 
        public string SeasonId { get; set; } 
    } 
    public class ResourceData 
    { 
        public string Id { get; set; } 
        public string Color { get; set; } 
    } 
} 

For more information about scheduler resources and grouping, please refer following documentation links. 

Kindly try the above solution and let us know if this meets your requirement. 

Regards, 
Praveenkumar 



HW Henryk Wisniewski October 7, 2021 07:10 PM UTC

Hello.

Please note, that Your 'AppointmentData' contains only a single SeasonId variable, where our requirements state that single appointment have 0, 1 or many Seasons.

I was hinting at this issue when talking about  AllowGroupEdit  = true, which is not set in Your example.
'AppointmentData'  has to have an array / list / ienumerable of Season Id's to work properly in our environment.

So, single appointment object must be able to hold more than one Season id and in this form it must be displayable by scheduler. There cannot be a multiple duplicated appointments only differing by season id.

Another thing - there is no clear solution for appointments without set season. How will they be displayed?



PN Praveenkumar Narasimhanaidu Syncfusion Team October 8, 2021 04:22 PM UTC

Hi Henryk , 
  
Thanks for your update. 
  
We have modified the sample according to your requirement which can be download from the following link. 
  
<SfSchedule TValue="AppointmentData" Height="550px" @bind-SelectedDate="@CurrentDate"> 
    <ScheduleGroup Resources="@Resources" AllowGroupEdit="true"></ScheduleGroup> 
    <ScheduleResources
        <ScheduleResource TItem="ResourceData" TValue="string[]" DataSource="@SeasonsData" Field="SeasonId" Title="Season" Name="Seasons" TextField="Id" IdField="Id" ColorField="Color" AllowMultiple="true"></ScheduleResource
    </ScheduleResources
    <ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings
    <ScheduleViews
        <ScheduleView Option="View.Day"></ScheduleView
        <ScheduleView Option="View.Week"></ScheduleView
        <ScheduleView Option="View.WorkWeek"></ScheduleView
        <ScheduleView Option="View.Month"></ScheduleView
        <ScheduleView Option="View.Agenda"></ScheduleView
    </ScheduleViews
</SfSchedule
@code{ 
        DateTime CurrentDate = new DateTime(2020, 1, 31); 
    public string[] Resources { get; set; } = { "Seasons" }; 
    List<AppointmentData> DataSource = new List<AppointmentData> 
        new AppointmentData { Id = 1, Subject = "Meeting", StartTime = new DateTime(2020, 1, 31, 9, 30, 0) , EndTime = new DateTime(2020, 1, 31, 11, 0, 0), SeasonId = new string[] {"Season1", "Season2" }
    }; 
    public List<ResourceData> SeasonsData { get; set; } = new List<ResourceData> 
        new ResourceData{ Id = "Season1", Color = "#ffaa00" }, 
        new ResourceData{ Id = "Season2", Color = "#f8a398" }, 
        new ResourceData{ Id = "Season3", Color = "#7499e1" } 
    }; 
    public class AppointmentData 
    { 
        public int Id { get; set; } 
        public string Subject { get; set; } 
        public string Location { get; set; } 
        public DateTime StartTime { get; set; } 
        public DateTime EndTime { get; set; } 
        public string Description { get; set; } 
        public bool IsAllDay { get; set; } 
        public string RecurrenceRule { get; set; } 
        public string RecurrenceException { get; set; } 
        public Nullable<int> RecurrenceID { get; set; } 
        public string[] SeasonId { get; set; } 
    } 
    public class ResourceData 
    { 
        public string Id { get; set; } 
        public string Color { get; set; } 
    } 
  
Query: there is no clear solution for appointments without set season. How will they be displayed? 
  
We let you know that it is mandatory to set season to render events on scheduler UI while using Grouping. If not provided season, the appointment will not render. 
  
Please get back to us for further assistance. 
  
Regards, 
Praveenkumar 


Loader.
Up arrow icon