@{
ViewBag.Title = "ScheduleFeatures";
}
<input type="button" name="button" value="Click Me" onclick="appWindow()" />
<input type="button" name="button1" value="Click Me to Add appointment" onclick="openWindow()" />
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.CurrentDate(new DateTime(2015, 11, 12))
.AppointmentSettings(fields => fields.Datasource(ViewBag.datasource)
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.StartTimeZone("StartTimeZone")
.EndTimeZone("EndTimeZone")
.EndTime("EndTime")
.Description("Description")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule")
)
)
<script>
function appWindow() { // function will be called when the button is clicked
var obj = $("#Schedule1").data("ejSchedule");
var app = new ej.DataManager(obj._currentAppointmentData).executeLocal(new ej.Query().where("Id", ej.FilterOperators.equal, 1)); // filtering the appointment based on the known Id value
obj._showAppointmentDetails(app[0]["Guid"], true); // opening the app window with the filtered appointment Guid value.
}
function openWindow() {
var obj = $("#Schedule1").data("ejSchedule");
obj._currentAction = 'add'
if (ej.isNullOrUndefined(obj._appointmentAddWindow))
obj._renderAppointmentWindow();
var start = new Date(obj.currentDate()); // start time of the appointment will be retrieved
var starthr = 30 * Math.round(start.getMinutes() / 30); // here we are rounding off the minutes
if (starthr == 60) {
start.setHours(start.getHours() + 1); // here we are incrementing the start hour when the minutes is equal to 60
}
start.setMinutes((Math.round(start.getMinutes() / 30) * 30) % 60); // here we are adding the round off start minutes to the appointment
var end = new Date(obj.currentDate().setMinutes(obj.currentDate().getMinutes() + 30));
var endhr = 30 * Math.round(end.getMinutes() / 30);
if (endhr == 60) {
end.setHours(end.getHours() + 1);
}
end.setMinutes((Math.round(end.getMinutes() / 30) * 30) % 60);
obj._appointmentAddWindow.find("#" + obj._id + "startdate").ejDatePicker("option", "value", ej.format(start, obj._datepattern(), obj.model.locale));
obj._appointmentAddWindow.find("#" + obj._id + "enddate").ejDatePicker("option", "value", ej.format(end, obj._datepattern(), obj.model.locale));
obj._appointmentAddWindow.find("#" + obj._id + "starttime").ejTimePicker("option", "value", ej.format(start, obj._pattern.t, obj.model.locale));
obj._appointmentAddWindow.find("#" + obj._id + "endtime").ejTimePicker("option", "value", ej.format(end, obj._pattern.t, obj.model.locale));
var stZoneValue = (obj.model.timeZone == null) ? obj._timezoneStringValue() : obj.model.timeZone;
stZoneValue = stZoneValue.indexOf("UTC") != 0 ? "UTC " + stZoneValue : stZoneValue;
var edZoneValue = (obj.model.timeZone == null) ? obj._timezoneStringValue() : obj.model.timeZone;
edZoneValue = edZoneValue.indexOf("UTC") != 0 ? "UTC " + edZoneValue : edZoneValue;
var stvalue = obj._findResourceIndex(obj.model.timeZoneCollection.dataSource, obj.model.timeZoneCollection["value"], stZoneValue);
var edvalue = obj._findResourceIndex(obj.model.timeZoneCollection.dataSource, obj.model.timeZoneCollection["value"], edZoneValue);
obj._appointmentAddWindow.find("#" + obj._id + "startTimeZone").ejDropDownList("option", { text: obj.model.timeZoneCollection.dataSource[stvalue][obj.model.timeZoneCollection["text"]], value: obj.model.timeZoneCollection.dataSource[stvalue][obj.model.timeZoneCollection["value"]] });
obj._appointmentAddWindow.find("#" + obj._id + "endTimeZone").ejDropDownList("option", { text: obj.model.timeZoneCollection.dataSource[edvalue][obj.model.timeZoneCollection["text"]], value: obj.model.timeZoneCollection.dataSource[edvalue][obj.model.timeZoneCollection["value"]] });
obj._appointmentAddWindow.ejDialog("open");
}
</script> |
@Html.EJS().Schedule("schedule").Width("100%").CurrentView(Syncfusion.EJ2.Schedule.View.Agenda).SelectedDate(new DateTime(2018,08,20)).Height("550px").EventSettings(es => es.DataSource(dataManger =>
{
dataManger.Url("/Home/LoadData").CrudUrl("/Home/UpdateData").CrossDomain(true).Adaptor("UrlAdaptor");
})).ActionBegin("onActionBegin").Render()
<script>
function onActionBegin(args) {
if (args.requestType === 'toolbarItemRendering') {
var addIcon = {
align: 'Right', prefixIcon: 'e-icon-add', text: 'newEvent',
cssClass: 'e-add', overflow: 'Show'
};
args.items.push(addIcon);
}
}
</script> |