var scheduleInfo = ig_getWebScheduleInfoById("WebScheduleInfo1");
The WebSchedule™ allows activities to be deleted Client-Side. This walk through goes over how you delete an activity client-side. The main method used to delete an activity client-side is called deleteActivity.
The deleteActivity method takes two parameters:
Activity: the actual activity object you wish to delete.
id: a string value which is retrievable in the Deleting Client and Server events.
The following JavaScript code will demonstrate how to dynamically delete and activity client-side.
Setup Project Create an ASP.NET project and setup the WebSchedule controls. For information on how to do this you can review the Quick Start using the Web Forms Designer or Setting Up the WebSchedule in Code.
After you have the project setup you will need to have a button or something that you can click to trigger a JavaScript event.
Getting Reference to WebScheduleInfo
First you will need a reference to the WebSchdeuleInfo™ object. You can get this object by passing in the ClientId of your WebScheduleInfo into the following utility function:
In JavaScript:
var scheduleInfo = ig_getWebScheduleInfoById("WebScheduleInfo1");
Getting the Activity Next you will need to get the activity you wish to dlete. The following are two of the more common ways to get an activity.
First you can loop through each activity in the activities collection:
In JavaScript:
var activities = scheduleInfo.getActivities(); var activity = null; for(var i = 0; i < activities.length; i++) { if(activities[i].getSubject() == "New Appointment") { activity = activities[i]; break; } }
Second you can use getSelectedActivity() method which can be found on either the WebDayView and WebMonthView.
In JavaScript:
var webDayView = ig_getWebDayViewById("WebDayView1"); var activity = webDayView.getSelectedActivity();
Delete Activity Finally you can call deleteActivity, which is a method off of the WebScheduleInfo object. This method will trigger a postback and both the client and server side Deleting events.
In JavaScript:
scheduleInfo.deleteActivity(appointment, "");
This is the recommended way to go about deleting an activity client-side.
This walkthrough was designed to explain the steps to deleting an Activity client-side.