Hi Andrew,
Thank you for contacting Syncfusion Support.
Q1: Searching custom fields.
To search the custom fields of Schedule, we need to pass the custom field name as parameter to the searchAppointments client-side public method. In the code you have shared, only search string is passed as a parameter which only searches the default fields of the Scheduler. We have prepared the sample for your reference which can be downloaded from the below location.
<Code>
function searchKeyUp(args) {
var searchString = $("#txtSearch").val();
var schObj = $("#Schedule1").data("ejSchedule");
var fields = ["Status", "Subject"]
var result = schObj.searchAppointments(searchString, fields);
showResult(result, searchString);
}
</Code>
In the above sample, we have passed the fields “Status”(custom field) and “Subject”(default field) to the public method SearchAppointments.
Q2:Preventing overlapping appointments
There is no built-in scheduler event to prevent the overlapping of appointments. We suggest you to make use of the schedule client-side events to validate it and display alert from there. Kindly refer the below code snippet to prevent the overlapping of appointments by validating through client-side.
<Code>
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.CurrentDate(new DateTime(2017, 6, 5))
.AppointmentSettings(fields => fields.Datasource(ViewBag.datasource)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.EndTime("EndTime")
.Description("Description")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule")
)
.ScheduleClientSideEvents(evt =>
evt.Create("onCreate")
.BeforeAppointmentCreate("onValidation")
.BeforeAppointmentChange("onValidation")
.DragStop("onValidation")
.ResizeStop("onValidation"))
)
function onValidation(args) {
if (args.type == "beforeAppointmentChange") {
app = args.appointment.changed[0];
}
else {
if (ej.isNullOrUndefined(args.appointment[0]))
app = args.appointment;
else
app = args.appointment[0];
}
overlapList = this._overlapApp(app["AppTaskId"], app[this._appointmentSettings["startTime"]], app[this._appointmentSettings["endTime"]], "");
if (args.type != "beforeAppointmentCreate" && overlapList.length > 1)
args.cancel = true;
else if (args.type == "beforeAppointmentCreate" && overlapList.length > 0)
args.cancel = true;
}
</Code>
Kindly refer the above sample code and let us know, if you need any further assistance on this.
Regards,
Nevitha.