How to hide or disable delete button of Appointment

4 posts, 1 answers
  1. wang zhong
    wang zhong avatar
    29 posts
    Member since:
    Jan 2010

    Posted 13 Apr 2010 Link to this post

    Hi All
    I don't want to delete Some Appointments,
    So i want hide or disable the delete button of appointment(The small icon likes X at upper right).
    How can i implement it?


    I see following codes at telerik,but silverlight schedulers does not suppout it.

        if (MyCondition)  
            {  
                e.Appointment.AllowDelete = false;  
                e.Appointment.AllowEdit = false;          
            }  

    Is there any suggestion?

  2. Answer
    Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 16 Apr 2010 Link to this post

    Hello wang zhong,

    Thank you for contacting us.

    To cancel the deletion of an appointment you will have to do the following:
    1. Create a Custom Appointment with boolean property, for example CanDelete.
    2. To stop the executing of the delete Command use the following code:

    public MainPage()
    {
        InitializeComponent();
          
        CommandManager.AddPreviewExecutedHandler(this.scheduler, new ExecutedRoutedEventHandler(ExecutedEventHandler));
          
    }
    private void ExecutedEventHandler(object a, ExecutedRoutedEventArgs e)
    {
          
        if (e.Command == RadSchedulerCommands.DeleteAppointment)
        {
            var app = ((Occurrence)e.Parameter).Appointment;
            if (!app.CanDelete)
            {
              e.Handled = true;
            }
        }
          
    }

    3. Then to hide the X button you have 2 options:
    a) create and apply a custom theme to the Scheduler. The explanation applies for Silverlight too. Then using a Converter to manipulate the visibility of the Delete button.
    You can find information how a Converter is created and applied here:
    - http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx
    - http://blogs.telerik.com/hristoborisov/posts/09-04-29/using_ivalueconverter_to_format_values_in_radcontrols_for_silverlight.aspx
    - http://blogs.telerik.com/rosif/posts/09-08-25/mark_working_hours_and_days_in_different_colors_with_radscheduler_for_silverlight.aspx
    b) to use the AppointmentTemplateSelector property and customize the appointment without the delete button. I happened to have a ready project illustrating the use of TimeSlotTemplateSelector. Attached I am sending it to you as the logic is pretty much the same. The only different thing is that the AppointmentTemplateSelector returns AppointmentSlot and to remove the button you will need to parse it to an AppointmentItem. Once you have the AppointmentItem it contains the PART_DeleteButton control and you can remove it.

    If you need further assistance please feel free to contact us again.

    Best wishes,
    Konstantina
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Terry Newton
    Terry Newton avatar
    21 posts
    Member since:
    Oct 2009

    Posted 20 Apr 2010 Link to this post

    I am interested in doing the same thing, so I downloaded this project.  After looking over it I see code to do many things I am trying to do.  Unfortunately the code does not appear to work for the color related effects.  I do not see how the TimeSlotTemplateSelector  is tied in.  I do not see either of the converters tied in the way I would expect them to be.  Is this code missing anything?  when I comment back in the initialization code and set breakpoints I see the appointments, but none of the color effects.  Are these non functional in the example?
  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 21 Apr 2010 Link to this post

    Hello Terry,

    Thank you for contacting us.

    There was a problem with the implementation of the TimeSlotTemplateSelector in Windows7 theme, but it is fixed already. Because of this, the project is not working. If you remove from App.xaml.cs the theme you will be able to see the colouring of TimeSlots, or if you want to use Windows7 theme you have to migrate to the latest internal build where this issue is addressed.

    If you have any other questions please let us know.

    All the best,
    Konstantina
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top