|
@using Syncfusion.Blazor
@using Syncfusion.Blazor.Schedule
@using Syncfusion.Blazor.Data
@using Newtonsoft.Json
@using SchedulerWebApi.Models
<SfSchedule TValue="AppointmentData" Height="550px" CurrentView="View.Week" SelectedDate="@(new DateTime(2018, 4, 19))">
<ScheduleEvents TValue="AppointmentData"></ScheduleEvents>
<ScheduleEventSettings TValue="AppointmentData">
<SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>
</ScheduleEventSettings>
</SfSchedule>
@code {
static HttpClient client = new HttpClient();
public class CustomAdaptor : DataAdaptor
{
public async override Task<object> ReadAsync(DataManagerRequest dataManagerRequest, string key = null) //triggers on initial load
{
AppointmentData[] datasource = JsonConvert.DeserializeObject<AppointmentData[]>(json);
foreach(string KeyValue in dataManagerRequest.Params.Keys)
{
Console.WriteLine(KeyValue + ":" + dataManagerRequest.Params[KeyValue]); // Here you can get start and end date of the scheduler's current view
}
return dataManagerRequest.RequiresCounts ? new DataResult() { Result = datasource, Count = datasource.Count() } : (object)datasource;
}
}
} |
|
@code {
static HttpClient client = new HttpClient();
public class CustomAdaptor : DataAdaptor
{
public async override Task<object> ReadAsync(DataManagerRequest dataManagerRequest, string key = null) //triggers on initial load
{
// ReadAsync method content
}
public async override Task<object> InsertAsync(DataManager dataManager, object data, string key)
{
// InsertAsync method content }
public async override Task<object> UpdateAsync(DataManager dataManager, object data, string keyField, string key)
{
// UpdateAsync method content
}
public async override Task<object> RemoveAsync(DataManager dataManager, object data, string keyField, string key) //triggers on appointment deletion through public method DeleteEvent
{
// RemoveAsync method content
}
public async override Task<object> BatchUpdateAsync(DataManager dataManager, object changedRecords, object addedRecords, object deletedRecords, string keyField, string key, int? dropIndex)
{
object records = deletedRecords;
List<AppointmentData> deleteData = deletedRecords as List<AppointmentData>;
foreach (var data in deleteData)
{
var json = await client.DeleteAsync(uri);
records = deletedRecords;
}
List<AppointmentData> addData = addedRecords as List<AppointmentData>;
foreach (var data in addData)
{
var formContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("Id", data.Id.ToString()),
new KeyValuePair<string, string>("Subject", data.Subject),
new KeyValuePair<string, string>("StartTime", data.StartTime.ToString()),
new KeyValuePair<string, string>("EndTime", data.EndTime.ToString()),
new KeyValuePair<string, string>("RecurrenceID", data.RecurrenceID.ToString()),
new KeyValuePair<string, string>("RecurrenceRule", data.RecurrenceRule),
new KeyValuePair<string, string>("RecurrenceException", data.RecurrenceException),
new KeyValuePair<string, string>("IsAllDay", data.IsAllDay.ToString())
});
records = addedRecords;
}
List<AppointmentData> updateData = changedRecords as List<AppointmentData>;
foreach (var data in updateData)
{
var formContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("Id", data.Id.ToString()),
new KeyValuePair<string, string>("Subject", data.Subject),
new KeyValuePair<string, string>("StartTime", data.StartTime.ToString()),
new KeyValuePair<string, string>("EndTime", data.EndTime.ToString()),
new KeyValuePair<string, string>("RecurrenceID", data.RecurrenceID.ToString()),
new KeyValuePair<string, string>("RecurrenceRule", data.RecurrenceRule),
new KeyValuePair<string, string>("RecurrenceException", data.RecurrenceException),
new KeyValuePair<string, string>("IsAllDay", data.IsAllDay.ToString())
});
records = changedRecords;
}
return records;
}
}
} |
Hi Alex,
We are glad to announce that our Essential Studio 2020 Volume
3 release v18.3.0.35 is rolled out. In
that release, We have fixed the reported issue. So please update your package
to this version to include the fix.
NuGet Link: https://www.nuget.org/packages/Syncfusion.Blazor/18.3.0.35
Release notes: https://blazor.syncfusion.com/documentation/release-notes/18.3.35/?type=all#scheduler
We thank you for your support and appreciate your patience
in waiting for this release. Please get in touch with us if you would require
any further assistance.
Regards,
Vengatesh