Hi Stefano,
Thanks for Contacting Syncfusion support.
Please find the following responses for your queries:
Query #1: Changing the query at runtime
You can change the Schedule control appointmentSettings query at runtime. Please refer to the following code example to meet your requirement.
<Code>
@{
ViewData["Title"] = "Home Page";
}
@{
List<string> views = new List<string>() { "Day", "Week", "WorkWeek", "Month", "Agenda" };
}
<div>
<ej-schedule id="Schedule1" width="100%" height="525px" views="views" current-view="Week" show-all-day-row="false"
read-only="false" locale="@(System.Threading.Thread.CurrentThread.CurrentCulture.Name)"
orientation="Vertical" enable-load-on-demand="true" action-begin="ScheduleBegin">
<e-appointment-settings apply-time-offset="false" id="Id" subject='"Subject"' start-time='"StartTime"' end-time='"EndTime"' description='"Description"' all-day='"AllDay"' recurrence='"Recurrence"' recurrence-rule='"RecurrenceRule"'>
<e-datamanager url="Home/GetData" crud-url="Home/Batch" adaptor="UrlAdaptor"></e-datamanager>
</e-appointment-settings>
</ej-schedule>
</div>
<div>
<ej-drop-down-list id="selectUser" target-id="usersList" width="200px" watermark-text="Select a User" change="dropValueChange"></ej-drop-down-list>
<div id="usersList">
<ul>
<li>Admin</li>
<li>Guest</li>
</ul>
</div>
</div>
<script>
var isQueryChanged = false;
function ScheduleBegin(args) {
if (!isQueryChanged) { // Here checking this value to prevent the below query update to Schedule appointmentSettings
this.model.appointmentSettings.query = ej.Query().from('ScheduleAppointment').where('Recurrence', 'equal', 'true');
test = this.model.appointmentSettings.query;
}
}
function dropValueChange(args) {
var name;
if (args.value === "Admin") {
name = args.model.text;
} else {
name = null;
}
var obj = $("#Schedule1").data("ejSchedule"); // object for schedule is created
var dataManager1 = ej.DataManager({
url: '@Url.Action("GetData","Home")',
crudUrl: '@Url.Action("Batch", "Home")',
crossDomain: true
});
var query = ej.Query().addParams("Value", name); // By using addParams we can send the parameter to controller for filtering
isQueryChanged = true; // Need to maintain this value to prevent appointmentSettings.query value updating in ScheduleBegin event
if (!ej.isNullOrUndefined(obj))
obj.option("appointmentSettings.query", query); // here we are assigning the query to schedule
}
</script>
</Code>
We have prepared the sample with the above code example, which can be downloaded from the following location. In this below sample, we have used the DropDownList control to maintain the User type (ex: Admin, Guest) and based on the selection, passed the selected value (if admin) as extra params in the query and assigned to the Schedule appointmentSettings.
Query #2: Why i need to use the UrlAdaptor?
We recommended you to use the WebApiAdaptor, as it will be working fine when the CRUD operations are performed on normal appointments, but not processing properly with the recurrence appointments due to the batch process taking place. Since, the batch editing will get performed, while editing the recurrence appointments and therefore, facing issues in that case. Currently, we are analyzing that scenario and will update the further details on this by 20th April, 2018.
Regards,
Velmurugan