<script type="text/javascript">
function onAppointmentClick(args) { // this function will be called when the appointment is clicked in schedule control
var obj = $("#FlatGrid").data("ejGrid"); // here we are creating object for Grid control
var app = obj.model.currentViewData; // here we will get the records in the Grid control
var appointment = ej.DataManager(app).executeLocal(new ej.Query().where("Id", ej.FilterOperators.equal, args.appointment.Id)); // here we will get the record selected in the schedule control
var rowIndex = $.inArray(appointment[0], app); // here we will get the row index of the selected record
obj.selectRows(rowIndex); // here the filtered record will be selected
}
function currentView(args) // this function will be called when the record is selected in Grid control
{
var date=args.data.StartTime.setHours(0, 0, 0); // here we will get the start time of the selected record
$("#Schedule1").ejSchedule("option", "currentDate", date); // here we are re-rendering the schedule control with the selected record's star time as current date
}
</script>
</Code>
Regards,
Karthigeyan
Hi Karthigeyan,Brilliant, thank you so much for the solution. Was wasting lot of time trying to figure out, thanks for the help.Is there way to refresh the schedule when a record is inserted via Gird and vice versa (when an appointment is made via schedule).Also is it possible to customize the schedule "Edit Appointment" / "Create Appointment" pop up window. Would like to change the heading, and labels and control placement etcRegardsPrasanth
@(Html.EJ().Grid<object>("FlatGrid")
.ClientSideEvents(ev => ev
.RecordClick("currentView") // this event will raise when the record in grid is clicked
.EndAdd("save") // this event will raise when the record is saved in grid
)
-----------
-----------
)
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("525px")
.ScheduleClientSideEvents(evt => evt
.AppointmentSaved("onAppointmentSave") // this event will raise when the appointment is saved
)
-----------
-----------
)
function save(args) // this function will be called when the record is saved in grid
{
var app = args.data; // appointment to be saved will be retrived
var obj = $("#Schedule1").data("ejSchedule"); // here we are creating object for Schedule control
if (args.data.AllDay == "false")
args.data.AllDay = JSON.parse("false")
else
args.data.AllDay = JSON.parse("true")
obj.saveAppointment(app); // here we are saving the appointment using public save function
obj.refresh() // to refresh the schedule
obj.refreshAppointments() // to referesh the schedule appointments
}
function onAppointmentSave(args) // this function will be called when the appointment is saved
{
var obj = $("#Schedule1").data("ejSchedule");
obj.refresh() // to refresh the schedule
obj.refreshAppointments() // to referesh the schedule appointments
}
</Code>
Query 2: Is it possible to customize the schedule "Edit Appointment" / "Create Appointment" pop up window ?
We have prepared a sample for your requirement which can be downloaded from the following location,
http://www.syncfusion.com/downloads/support/forum/121743/ze/custom_window420953694
In the above sample we have customized the default edit /create appointment window. In the custom window we have rendered the autocomplete control which holds the owner values. Kindly visit the below User Guide link to know more about the custom window.
Custom Window UG Link: http://help.syncfusion.com/aspnetmvc/schedule/customization#customized-appointment-window
Auto Complete UG Link: http://help.syncfusion.com/aspnetmvc/autocomplete/getting-started
Regards
Karthigeyan