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

Get Appointment's Id in ContextMenu's OnClientItemClicked Event Handler

2 Answers 125 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Albert
Top achievements
Rank 1
Albert asked on 16 Jul 2008, 09:59 PM
I am popping up a ContextMenu in the Scheduler's OnClientAppointmentContextMenu event.   Is it possible to get a reference to the client-side appointment object or at least it's Id value during the context menu's OnClientItemClicked event handler.

There is a get_targetElement() method but this returns a reference to the HTML element.  Is there any way to reference the appointment object that was clicked on inside of this event handler?

2 Answers, 1 is accepted

Sort by
0
Albert
Top achievements
Rank 1
answered on 16 Jul 2008, 10:18 PM

I'm not sure if this is how you intend it to work but I figured out a workaround.  Please let me know if there is a better way to do this.  I would prefer to get a reference to the appointment right inside the event handler if it is possible.

  1. I declared a page level variable named currentAppointment to store the last clicked on appointment object.
  2. During the OnClientAppointmentContextMenu event handler I'm setting this variable to eventArgs.get_appointment(). 
  3. Then in the OnClientItemClicked Event Handler of the ContextMenu I reference this page level variable.
    var currentAppointment = null;  
      
    function ShowAppointmentContextMenu(sender, eventArgs)  
    {  
       currentAppointment = eventArgs.get_appointment();  
       var menu = $find('<%=AppointmentContextMenu.ClientID %>');  
       menu.show(eventArgs.get_domEvent());  
    }         
 
    function AppointmentContextMenuItemClicked(sender, eventArgs)  
    {  
        var apptId = currentAppointment.get_id()  
    } 
0
Accepted
Peter
Telerik team
answered on 17 Jul 2008, 12:07 PM
Hi Albert,

That's exactly what I had in mind too. I was going to suggest the same approach but you have already figured it out.

Regards,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Scheduler
Asked by
Albert
Top achievements
Rank 1
Answers by
Albert
Top achievements
Rank 1
Peter
Telerik team
Share this question
or