ICS Export

Hi,

I see in your documentation that appointments can be exported to an ics file (i want to synchronize with Outlook), but in the chapter "Export/Print", there is only a sample for the "print" method.

How can i call the export method please ? 
(i tried obj.export(), obj.exportAll(), etc. , no one worked).

Thx by advance.
Fred.

1 Reply

VS Velmurugan S Syncfusion Team May 18, 2018 12:42 PM UTC

Hi Fred, 

Thanks for Contacting Syncfusion support. 

We have prepared the sample to meet your requirement exporting the schedule appointments into ICS file, which can be downloaded from the following location. 

 
In the above sample, we have displayed one button (ex: ICS Export) along with the Schedule control and binding click event to it. When you click on that button “onClick” method will trigger and within that we have called the Schedule export public method to export all the appointments. Also, added the option “Export Appointment” in Context Menu and while click on that will trigger “onMenuItemClick” method and called the exportSchedule method to export the single appointment. Please refer to the following code example used in the above sample for achieving the mentioned requirement. 

<Code> 
Index.cshtml page: 

<div> 
    <ej-button id="ExportBtn" size="Normal" show-rounded-corner="true" text="ICS Export" click="onClick"/> 
</div> 
<div> 
    <ej-schedule id="Schedule1" width="100%" height="525px" current-date="new DateTime(2018,4,25)" menu-item-click="onMenuItemClick"> 
        <e-context-menu-settings enable="true"> 
            <e-menu-items appointment="@ViewBag.appData"></e-menu-items> 
        </e-context-menu-settings> 
        <e-appointment-settings id="Id" apply-time-offset="false" 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> 
<script> 
    // Clicking on the export button will call this method 
    function onClick(args) { 
        var obj = $("#Schedule1").data("ejSchedule"); 
        // Calls the server-side action ExportToICS 
        obj.exportSchedule('@Url.Action("ExportToICS", "Home")', null, null); 
    } 
    // Clicking on the export appointment option in context menu will call this method 
    function onMenuItemClick(args) { 
        if (args.events.ID == "export") { 
            var obj = $("#Schedule1").data("ejSchedule"); 
            // Calls the server-side action ExportToICS method to export single appointment 
            obj.exportSchedule('@Url.Action("ExportToICS", "Home")', null, args.targetInfo.Id); 
        } 
    } 
</script> 
 
HomeController Page: 

public void ExportToICS() 
        { 
            IEnumerable data; 
            string JSONModel = Request.Form["ScheduleApps"]; 
            var model = JsonConvert.DeserializeObject<Dictionary<string, object>>(JSONModel); 
            var Id = Request.Form["AppointmentId"]; 
            if (Id.Count > 0) 
                // To export single appointment 
                data = _context.ScheduleAppointments.Where(app => app.Id.ToString() == Id.ToString()).ToList(); 
            else 
                // To export all the appointments 
                data = _context.ScheduleAppointments.ToList(); 
            ScheduleExport obj = new ScheduleExport(model, data, HttpContext); 
        } 

</Code> 

Also, we will draft the documentation for this requirement and add it to our UG document and publish it soon in our website. 

Kindly try with the above sample and let us know if you need any further assistance on this. 
Regards, 
Velmurugan

Loader.
Up arrow icon