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

Context Menu Target Element

8 Answers 283 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Lou
Top achievements
Rank 1
Lou asked on 18 Jul 2008, 01:06 PM
I'm having an issue with a context menu where the menu doesn't populate the _targetElement property within the eventargs. This only happens when a menu is used (right click) and then another item is right clicked to invoke the menu once again. I need to grab some values from the _targetElement. Code is below, can someone help out.

Thanks,

Lou


//-------------control declaration---------------
<telerik:RadContextMenu id="EmailRightClickEditMenu"
Skin="Context_Nav"
EnableEmbeddedSkins="false"
OnClientItemClicked = "EmailRightClickMenu_Clicked"
OnClientShowing="EmailRightClickMenu_Showing" runat="server">
<Items>
<telerik:RadMenuItem Value="Open" meta:resourcekey="OpenMenu" runat="server" />
<telerik:RadMenuItem Value="Reply" meta:resourcekey="ReplyMenu" runat="server" />
<telerik:RadMenuItem Value="Reply All" meta:resourcekey="ReplyAllMenu" runat="server" />
<telerik:RadMenuItem Value="Forward" meta:resourcekey="ForwardMenu" runat="server" />
<telerik:RadMenuItem Value="Delete" meta:resourcekey="DeleteMenu" runat="server" />
</Items>
</telerik:RadContextMenu>
//------------------------------------------------------------------------

//--------------------javascript 

function

Email_MenuItemClicked(sender, args)

{

var itemValue = args.get_item().get_value();

var target = GetFirstParent(args.get_item().get_element(), NodeHasAttribute('UpdatePanel'));

switch (itemValue)

{

case "New":

ComposeEmail(target,

null);

break;

case "Delete":

DeleteSelected(

'tblEmails');

break;

case "Reply":

ReplySelected(

'tblEmails', target);

break;

case "ReplyAll":

ReplyAllSelected(

'tblEmails', target);

break;

case "Forward":

ForwardSelected(

'tblEmails', target);

break;

}

}

 

/*

This function is fired by the Telerik Context Menu when the user right-clicks

It sets the row clicked over top of as the selected row

*/

 

function

EmailRightClickMenu_Showing(sender, args)

{

var target = GetFirstParent(args.get_targetElement(), NodeHasAttribute('UpdatePanel'));

SetSelected(target,

'selectedRow');

var Reply = sender.findItemByText('Reply');

var ReplyAll = sender.findItemByText('Reply to All');

var Forward = sender.findItemByText('Forward');

var selRows = getSelectedRows('tblEmails');

if (selRows.length > 1)

{

Reply.disable();

ReplyAll.disable();

Forward.disable();

}

else

 

{

Reply.enable();

ReplyAll.enable();

Forward.enable();

}

}

 

/*

This function is the event handler for both right-click context menu

Controls all behavior of the menu

*/

 

function

EmailRightClickMenu_Clicked(sender, args)

{

var itemValue = args.get_item().get_value();

var target = GetFirstParent(args.get_targetElement(), NodeHasAttribute('UpdatePanel'));

switch(itemValue)

{

case "Delete":

DeleteSelected(

'tblEmails');

break;

case "Open":

EditSelected(

'tblEmails', target);

break;

case "Forward":

ForwardSelected(

'tblEmails', target);

break;

case "Reply" :

ReplySelected(

'tblEmails', target);

break;

case "Reply All" :

ReplyAllSelected(

'tblEmails', target);

break;

}

}

//-----------------------------------------------------------------------


args.get_targetElement() == null after the second right click to display another context menu.

8 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 21 Jul 2008, 03:23 PM
Hi Lou,

I tried to reproduce the problem on my side and everything worked normally - get_targetElement() always returned the div element of the Context Menu.

I attached my test page to this post for you to examine it.

Have I missed something in reproducing the problem? What can I change in this page, so that the problem starts to occur?

Regards,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Lou
Top achievements
Rank 1
answered on 21 Jul 2008, 05:07 PM
I can consistantly reproduce this error on my side, we are handling the right mouse click, but it shouldn't effect this menu. I've debugged, and it seems the control is always returning a "null" value for the get_targetElement() method.
0
Lou
Top achievements
Rank 1
answered on 22 Jul 2008, 08:25 PM
Noone can help with this issue? Is there any reason you can think of that an opened menu would return a "null" value for the args.get_targetElement(). I've got it narrowed down, but when the event is returning null it's very hard to debug...

Any suggestions on another debugging viewpoint?
0
Simon
Telerik team
answered on 23 Jul 2008, 08:03 AM
Hello Lou,

It seems that you have not specified Target Elements to the Context Menu, so it leaves the option of using the showAt function to show the Menu. If this is the case, then get_targetElement will return null and that is normal.

How exactly are you opening the Context Menu?

Greetings,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Lou
Top achievements
Rank 1
answered on 23 Jul 2008, 01:28 PM
target elements are all set when I look at the sender, I just can't find which one was clicked.

The problem doesn't happen in FireFox. I'm using an IE7 browser to test. It looks as though events are getting fired out of order. I'm getting the OnClientHidden event after the OnClientShown event when I try to do it in IE7... not sure if that will help you or not.
0
Simon
Telerik team
answered on 23 Jul 2008, 02:01 PM
Hi Lou,

Thank you for the additional information.

We have encountered this kind of problem recently and we fixed it. Please upgrade to the latest version of Telerik.Web.UI.

Regards,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Lou
Top achievements
Rank 1
answered on 23 Jul 2008, 05:02 PM
I've just downloaded and updated my Telerik.Web.UI.dll. I am having the same issue with the control behavior (still works in FireFox and not IE) and now I have formatting issues around the controls.

Simon, is there a way that I can get you to remote into my machine to see the behavior I'm talking about?
0
Simon
Telerik team
answered on 24 Jul 2008, 03:28 PM
Hello Lou,

Indeed further investigation of the case is required.

However, GoTo Meetings are available only to Enterprise Customers. So in this case I would like to ask you to prepare a small sample project, where the erroneous behavior can be observed, and send it to me. I will investigate it and will try to find a solution or a workaround.

All the best,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Menu
Asked by
Lou
Top achievements
Rank 1
Answers by
Simon
Telerik team
Lou
Top achievements
Rank 1
Share this question
or