|
...
<EjsSchedule TValue="AppointmentData" Width="100%" Height="650px" SelectedDate="@(new DateTime(2020, 1, 31))">
...
<ScheduleEvents TValue="AppointmentData" ActionCompleted="ActionCompleted"></ScheduleEvents>
<ScheduleEventSettings DataSource="@DataSource" AllowDeleting="false"></ScheduleEventSettings>
</EjsSchedule>
@code{
[Inject]
protected IJSRuntime JsRuntime { get; set; }
protected override void OnAfterRender(bool firstRender)
{
this.JsRuntime.Ejs().LoadLocaleData("Pages/locale.json");
}
public void ActionCompleted(ActionEventArgs<AppointmentData> args)
{
if(args.RequestType == "eventCreate")
{
// Triggers on successful completion of scheduler event create actions
}
else if(args.RequestType == "eventChange")
{
// Triggers on successful completion of scheduler event change actions
}
}
}
<style>
.e-schedule-dialog .e-event-delete:disabled {
display: none; // hide the disabled delete button
}
</style> |
|
<EjsSchedule @ref="LookSchedule" TValue="ViewModel.Look" Height="100%" Width="100%" CurrentView="View.Month" AllowDragAndDrop="false" AllowResizing="false"
RowAutoHeight="true" FirstDayOfWeek="1" ShowQuickInfo="false">
<ScheduleWorkHours Highlight="false" />
<ScheduleEvents TValue="ViewModel.Look" Navigating="NavigatingHandler" EventRendered="OnEventRenderedHandler" OnPopupClose="PopupClose"/>
<ScheduleViews>
<ScheduleView Option="View.Month" />
<ScheduleView Option="View.Week">
<ScheduleViewTimeScale Interval="60" SlotCount="2" />
</ScheduleView>
<ScheduleView Option="View.Day" />
</ScheduleViews>
<ScheduleTemplates>
<EditorTemplate>
@{
var entity = (context as ViewModel.Look);
<input type="hidden" name="Id" class="e-field" value="@(entity.Id)" />
<table class="custom-event-editor" width="100%" cellpadding="5">
<tbody>
<tr>
<td class="e-textlabel">Craft</td>
<td colspan="4">
<EjsTextBox Id="Craft" CssClass="e-field e-input" Value="@(entity.Craft)"></EjsTextBox>
</td>
</tr>
<tr>
<td class="e-textlabel">Site</td>
<td colspan="4">
<EjsTextBox Readonly="true" Id="Site" CssClass="e-field e-input" Value="@(entity.Site)"></EjsTextBox>
</td>
</tr>
<tr>
<td class="e-textlabel">Time</td>
<td colspan="4">
<EjsTextBox Readonly="true" Id="Time" CssClass="e-field e-input" Value="@($"{entity.StartTime.ToUniversalTime().ToString("hh:mm tt")} - {entity.EndTime.ToUniversalTime().ToString("hh:mm tt")}")"></EjsTextBox>
</td>
</tr>
<tr style="display: none;"> // Need to maintain the DateTime filed to handle scheduler actions and based on your wish you can hide or display this field
<td class="e-textlabel">DateTime</td>
<td colspan="4">
<EjsTextBox Readonly="true" Id="DateTime" CssClass="e-field e-input" Value="@($"{entity.StartTime.ToUniversalTime().ToString()} - {entity.EndTime.ToUniversalTime().ToString()}")"></EjsTextBox>
</td>
</tr>
<tr>
<td class="e-textlabel">Status</td>
<td colspan="4">
<EjsTextBox Readonly="true" Id="Status" CssClass="e-field e-input" Value="@(entity.Status)"></EjsTextBox>
</td>
</tr>
...
@code{
[Inject] protected IJSRuntime JsRuntime { get; set; }
Dictionary<string, object> StartName = new Dictionary<string, object>()
{
{"data-name","StartTime"},
};
Dictionary<string, object> EndName = new Dictionary<string, object>()
{
{"data-name","EndTime"},
};
public void PopupClose(PopupCloseEventArgs<ViewModel.Look> args)
{
if(args.Type == PopupType.Editor && args.Data != null)
{
args.Data.StartTime = Convert.ToDateTime(args.Data.DateTime.Split(" - ")[0]); // Need to be convert the string to date time object to avoid serialization issue
args.Data.EndTime = Convert.ToDateTime(args.Data.DateTime.Split(" - ")[1]);
}
}
}
|
|
@using Syncfusion.EJ2.Blazor.Schedule
<EjsSchedule TValue="AppointmentData" Height="650px" SelectedDate="new DateTime(2019, 1, 17)">
<ScheduleEvents TValue="AppointmentData" EventRendered="OnEventRendered"></ScheduleEvents>
<ScheduleViews>
<ScheduleView Option="View.Day"></ScheduleView>
<ScheduleView Option="View.Week"></ScheduleView>
<ScheduleView Option="View.Month"></ScheduleView>
<ScheduleView Option="View.WorkWeek"></ScheduleView>
</ScheduleViews>
<ScheduleEventSettings DataSource="@DataSource"></ScheduleEventSettings>
</EjsSchedule>
@code{
public async Task OnEventRendered(EventRenderedArgs<AppointmentData> args)
{
string style = (await args.Element.GetAttribute("style")).ToString(); // Get style attribute of the element
style += "background:" + args.Data.CategoryColor; // concatenate the background color
args.Element.SetAttribute("style", style); // Reset the values of style attribute
}
List<AppointmentData> DataSource = new List<AppointmentData>
{
new AppointmentData { Id = 3, Subject = "South Park", StartTime = new DateTime(2019, 1, 17, 9, 30, 0) , EndTime = new DateTime(2019, 1, 17, 11, 0, 0), CategoryColor= "#df5286" },
new AppointmentData { Id = 1, Subject = "Vikings", StartTime = new DateTime(2019, 1, 15, 9, 30, 0) , EndTime = new DateTime(2019, 1, 15, 11, 0, 0), CategoryColor= "#7fa900" },
new AppointmentData { Id = 2, Subject = "Rick and Morty", StartTime = new DateTime(2019, 1, 27, 9, 30, 0) , EndTime = new DateTime(2019, 1, 27, 11, 0, 0),
RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=5", CategoryColor= "#1aaa55" }
};
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 CategoryColor { get; set; }
}
} |