Hello.
I would like to see your way of providing multiple resources for scheduler.
Given that:
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).
|
<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; }
}
} |
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?
|
<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; }
}
} |