Context menu has no context in Opened event

4 posts, 0 answers
  1. Daniel Billingsley
    Daniel Billingsley avatar
    95 posts
    Member since:
    Apr 2010

    Posted 01 Jun 2010 Link to this post

    I am using a RadContextMenu on a RadScheduler.

    I have hooked to the Opened event in order to dynamically control the menu, but I need to do that based on the appointment that was the target of the right-click.  For example, I want to disable the "Edit Appointment" option if the user doesn't have permission to edit the particular appointment.

    I can use the GetClickedElement property in the ItemClick event, but it doesn't work in the Opened event.

    The following code seems to work in the Opened event.  From the AppointmentSlot I can of course get to my appointment.  Is there any problem with this:

     

     

     

    Border apptBorder = (sender as RadContextMenu).GetClickedElement<Border>();

     

     

     

    AppointmentSlot apptSlot = apptBorder.DataContext as AppointmentSlot;

     

  2. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 02 Jun 2010 Link to this post

    Hi Daniel Billingsley,

    You should use AppoitnmentItem instead of Border because there are a lot of borders in the Scheduler template.
    AppointmentItem appItem = (sender as RadContextMenu).GetClickedElement<AppointmentItem>();
    if(appItem != null)
    {
       AppointmentSlot slot = appItem.AppointmentSlot;
    }

    Let us know if you need more information.

    Regards,
    Hristo
    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. Daniel Billingsley
    Daniel Billingsley avatar
    95 posts
    Member since:
    Apr 2010

    Posted 02 Jun 2010 Link to this post

    As I said in my original post, that doesn't work for me in the Opened event.  Specifically, the call to GetClickedElement<AppointmentItem> does not find any appointment.  It works fine in the ItemClicked event, but not the Opened event.

    That's why I came up with this workaround, which I understand is a little fragile, but it seems to consistently find the first border walking up the visual tree - which is the one around the textbox displaying the appointment subject on the calendar.
  5. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 03 Jun 2010 Link to this post

    Hello Daniel Billingsley,

    Could you send us sample project where we can observe this issue?

    All the best,
    Hristo
    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