This is a migrated thread and some comments may be shown as answers.
AllowDelete = False
1 Answer 29 Views
This is a migrated thread and some comments may be shown as answers.
CodeR
Top achievements
Rank 2
CodeR asked on 17 Dec 2009, 06:42 AM
Hi,

I'm trying to prevent particular users from being able to delete appointments but not having much luck so far.

Following the various threads on the same topic I've added the logic into the AppointmentDataBound event.

Protected Sub rd_Schedule_AppointmentDataBound(ByVal sender As ObjectByVal e As SchedulerEventArgs)  
         
        'Control Access to Edit and Delete Appointments  
        If Page.User.IsInRole("BasicAccess") then  
              e.Appointment.AllowDelete = False 
        End If 
 
End Sub 

In stepping through the code the if statement happily evaluates to true and then sets the e.Appointment.AllowDelete to false. However the context menu delete still causes the Confirm Delete Dialog to display and will still delete the appointment. I've added in the AppointmentDelete event and checked the AllowDelete for the appointment and it evaluates to false despite deleting the appointment.

Is there a more comprehensive example of this or anything I can look at that might be effecting it?
Cheers,
Damien

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 18 Dec 2009, 11:52 AM
Hello Damien,

Attach 'OnClientAppointmentContextMenuItemClicking' event to RadScheduler and check whether the AllowDelete property of appointment is set to True. If True, cancel the event using the args.set_cancel(true) method.

cs:
 
Protected Sub rd_Schedule_AppointmentDataBound(ByVal sender As ObjectByVal e As SchedulerEventArgs) 
        'Control Access to Edit and Delete Appointments   
        If Page.User.IsInRole("BasicAccess") then   
              e.Appointment.AllowDelete = False  
        End If  
End Sub  

javascript:
 
    function OnClientAppointmentContextMenuItemClicking(sender, args) { 
        if (args.get_item().get_text() == "Delete") {  // Check whether clicked on Delete 
            if (!args.get_appointment().get_allowDelete() && args.get_appointment().get_allowDelete()!=null) { 
                args.set_cancel(true);  // Cancel the event 
                alert("Cannot Delete"); 
            }             
        } 
    } 

-Shinu.
Asked by
CodeR
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 1
Share this question
or