Get the appointment clicked

Hi!

How can I get the appointment I've clicked to send to the controller?


<ejs-schedule id="schedule" dateFormat="dd/MM/yyyy" width="auto" height="800px" readonly="true" allowDragAndDrop="false" locale="pt" startHour="07:00" endHour="20:00">
    <e-schedule-timescale enable="true" interval="30" slotCount="1"></e-schedule-timescale>

    <e-schedule-eventsettings dataSource="@ViewBag.appointments">

        <e-eventsettings-fields id="AppoitmentID">
            <e-field-location name="Clinic" title="Nr. Clinic"></e-field-location>
            <e-field-subject name="PatientName" title="Patient Name"></e-field-subject>
            <e-field-description name="PatientTel" title="Phone"></e-field-description>
        </e-eventsettings-fields>
    </e-schedule-eventsettings>

</ejs-schedule>


3 Replies

VM Vengatesh Maniraj Syncfusion Team May 28, 2020 05:22 AM UTC

Hi Vially, 
 
Thanks for contacting Syncfusion Support. 
 
We have validated your requirement “How can I get the appointment I've clicked to send to the controller?” and we can get the appointment details by making use of the eventClick event like below, 
 
<ejs-schedule id="schedule" dateFormat="dd/MM/yyyy" width="auto" height="800px" selectedDate="new DateTime(2018, 2, 15)" readonly="true" allowDragAndDrop="false" startHour="07:00" endHour="20:00" eventClick="onEventClick"> 
        <e-schedule-timescale enable="true" interval="30" slotCount="1"></e-schedule-timescale> 
 
        <e-schedule-eventsettings dataSource="@ViewBag.datasource"> 
        </e-schedule-eventsettings> 
 
    </ejs-schedule> 
<script type="text/javascript"> 
    function onEventClick(args) { 
        // You can perform the action here 
    } 
</script> 
 
Please check the above code and get back to us if you need any further assistance. 
 
Regards, 
Vengatesh 



VI Vially Israel June 3, 2020 09:58 PM UTC

Hi! This didn't work. I know I have to use the eventClick but I want to get the exactly appointment I clicked.

With this code I get only the first appointment on the list, not there I clicked.

<script type="text/javascript">
    document.getElementById('schedule').ondblclick = function (args) {
        console.log(document.getElementById('schedule').ej2_instances[0].eventsData[0].AppointmentID);       
    };
</script> 


I want something like this code but getting the appointment I clicked.


VM Vengatesh Maniraj Syncfusion Team June 4, 2020 04:00 AM UTC

Hi Vially, 
 
Thanks for the update. 
 
You can get the selected event data with the help of activeEventData field like the below code, 
document.getElementById('schedule').ondblclick = function (args) { 
        if (args.target && args.target.classList.contains('e-appointment')) { 
            var schObj = document.getElementById('schedule').ej2_instances[0]; 
            console.log(schObj.activeEventData); 
        }   
    }; 
 
Please try the above code and get back to us if you need any further assistance. 
 
Regards, 
Vengatesh 


Loader.
Up arrow icon