Samsung Electronics logo

Managing Multiple Calendar Events in the Batch Mode



To create engaging applications with various calendar features, you must learn to manage multiple calendar events in the batch mode:

  1. Retrieve the default system calendar using the getDefaultCalendar() method of the CalendarManager interface.

    With the parameter, specify the calendar type as an event.

    myCalendar = webapis.calendar.getDefaultCalendar("EVENT");
    
  2. Retrieve all events stored in the calendar by using the find() method of the Calendar object:

    myCalendar.find(eventSearchSuccessCallback, errorCallback);
    Note
    To retrieve a specific set of events, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Calendar Filter Attributes).

    In this example, all the events are retrieved because no filter is used.

  3. To update events:
    1. Define the items to be updated in the success event handler of the find() method:

      function eventSearchSuccessCallback(events) 
      {
         events[0].description = "New Description 1";
         events[1].description = "New Description 2";
      
    2. Use the updateBatch() method to update multiple calendar items asynchronously:

         /* Update the first 2 existing events */
         myCalendar.updateBatch(events.slice(0, 2));
      }
      
  4. To delete events, use the removeBatch() method in the success event handler of the find() method to delete multiple calendar items asynchronously:

    function eventSearchSuccessCallback(events) 
    {
       /* Delete the first 2 existing events */
       myCalendar.removeBatch([events[0].id, events[1].id]);
    }