Welcome Guest Search | Active Topics | Sign In | Register

Grid and Contextmenu Options
Gunnar
Posted: Wednesday, July 29, 2009 4:23:09 PM
Rank: Member
Groups: Member

Joined: 7/17/2009
Posts: 17
I know this issue has been discussed in other threads and I have tried all the suggestions I have found without any luck.

I have a Grid, and I have a Contextmenu attached to that Grid. Plain and 'simple'.

When I right-click on the Grid I get my Contextmenu and when I select a choice in the menu I get the server side event that I expect.

BUT, the Grid.ContextItem and Grid.ContextCell are both null, so I haven't a clue where the Grid was clicked.

Are there any specific requirements for the ContextItem to be correctly assigned?

The Grid has FullRowMode=True. I have no client side scripts.
eo_support
Posted: Thursday, July 30, 2009 10:48:23 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Gunnar wrote:
I have no client side scripts.


That is definitely wrong then. :) You will need client side scripts to show context menu for the Grid.

Please see here for a working example of how to use context menu with Grid:

http://demo.essentialobjects.com/Default.aspx?path=Grid\_i1\_i22

Thanks!

Gunnar
Posted: Thursday, July 30, 2009 1:23:28 PM
Rank: Member
Groups: Member

Joined: 7/17/2009
Posts: 17
Quote:
You will need client side scripts to show context menu for the Grid


I don't get it.

I do not have any client scripts, yet the Contextmenu is displayed, I can use it and I get a server side event when I click a Contextmenu item that raises server events.

So, everything works as expected except for the fact that when I get the Contextmenu item event on the server side, Grid.ContextItem and Grid.ContextCell are both null.

I have no need for a client side script, and I cannot see anything in the client code you refer to that would change the fact that Grid.ContextItem and Grid.ContextCell are both null when I get the server side event. Or it it something in the script code that I miss?

eo_support
Posted: Thursday, July 30, 2009 1:42:41 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You do not need client side JavaScript to just show the context menu. But you must use JavaScript to handle the Grid's ClientSideOnContextMenu event to display the context menu so that Grid can correctly record ContextItem and ContextCell. Otherwise it will be exactly what you saw: you will get the context menu but not ContextItem and ContextCell.

Thanks
Gunnar
Posted: Thursday, July 30, 2009 3:21:13 PM
Rank: Member
Groups: Member

Joined: 7/17/2009
Posts: 17
OK thanks,

I finally got it to work now. This is excellent functionality, but you really need to describe it better.

When I re-read the description of the Grid.ContextItem Property I still can't see any requirements for the client side script to be present.

Quote:
When you use ClientSideOnContextMenu....it is often desired to know which item...


Yes, it is probably often desired when using ClientSideOnContextMenu, and most probably when not using ClientSideOnContextMenu also...

My suggestion is that you complement the documentation with a clear requirement that the ClientSideOnContextMenu must be used in order for the ContextItem to be present on the server side.

Also, the example code on the page you referred to is somewhat confusing:

Code: JavaScript
//Show the context menu
var menu = eo_GetObject("<%=Menu1.ClientID%>");
eo_ShowContextMenu(e, "<%=Menu1.ClientID%>");


Besides the fact that I never got this piece of code to find anything (using my control name of course), I can't understand the creation of the menu variable that is never used...

I got this to work though:

Code: JavaScript
//Show the context menu
var menu = eo_GetObject("Menu1");
eo_ShowContextMenu(e, menu.getId());


eo_support
Posted: Thursday, July 30, 2009 3:29:09 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Thank you very much for the feedback. It certainly makes perfect sense to clearly state that you must use ClientSideOnContextMenu in order for ContextItem and ContextCell to work.

The eo_GetObject in the sample is not necessary. It was there so that you can use it to modify the menu, which is often needed if you wish to modify the menu item text to reflect the current selected item cell (For example, change "Save" to "Save 'item A'", where 'Item A' is the selected cell content). Nevertheless, I agree with you that the code should comment it clearly.

Thanks!
Gunnar
Posted: Friday, July 31, 2009 3:57:23 PM
Rank: Member
Groups: Member

Joined: 7/17/2009
Posts: 17
I've found another mystery with the contextmenu on the grid. With all the client side and server side code in place, everything works as expected for all grid rows except the first one.

In the client side function I can see the "g_itemIndex = item.getIndex();" register the correct row index: 0 for first row, 1 for second row and so on.

On the server side, I get a correct Grid.ContextItem object for rows 1 and above. When the first row is right clicked, I get null in Grid.ContextItem.
eo_support
Posted: Friday, July 31, 2009 4:00:56 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

This looks like a bug. We will look into it and see what we can find.

Thanks!
eo_support
Posted: Tuesday, August 4, 2009 2:38:58 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

We looked into the issue but have not been able to reproduce it. Can you provide a test page that can reproduce the problem?

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.