This is a migrated thread and some comments may be shown as answers.

Context menu has no context in Opened event

3 Answers 31 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Daniel Billingsley
Top achievements
Rank 1
Daniel Billingsley asked on 01 Jun 2010, 09:00 PM

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;

 

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 02 Jun 2010, 09:45 AM
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.
0
Daniel Billingsley
Top achievements
Rank 1
answered on 02 Jun 2010, 01:26 PM
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.
0
Hristo
Telerik team
answered on 03 Jun 2010, 12:58 PM
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.
Tags
Menu
Asked by
Daniel Billingsley
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Daniel Billingsley
Top achievements
Rank 1
Share this question
or