iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Take a look at the following code. Here is how am adding context menu to my webgrid.
What am doing is moving the LoadMoreData option in context menu from the top position to the last one. This means my custom context menu items(which are X,Y) are always appear from top of the context menu and LoadMoreData as the third Item. Am hiding all other default context menu items in my code as shown below. The code is as told by the support team. The solution works fien for one time click. From the next click onwards, script error occurs. You can test the following code on any webgrid.
var i=0;function HandleRowContextMenu(controlId, rowType, rowElement, menuObject){ //==========Add Custom menu items to context menu===================// //View Menu var x = new WebMenuItem(); x.Text = 'X'; x.Name = "X"; x.ImageURL= "../CommonLibrary/Images/wg_view.gif" x.OnClick = "gotoX"; //Delete Menu var y = new WebMenuItem(); y.Text = Y'; y.Name = "Y"; y.ImageURL= "../CommonLibrary/Images/customer.gif" y.OnClick = "gotoY"; var grid = ISGetObject(controlId); menuObject.Items.Add(x); menuObject.Items.Add(y); //==========Hide Context menu items===================// menuObject.Items[5].Hide(); menuObject.Items[6].Hide(); menuObject.Items[7].Hide(); menuObject.Items[30].Hide(); menuObject.Items[31].Hide(); menuObject.Items[34].Hide(); menuObject.Items[35].Hide(); if(i!=1) { var loadMoreItem = menuObject.Items.GetNamedItem("mnuLoadMore"); menuObject.Items.Move(32, menuObject.Items.length - 1); //Move mnuLoadMore to last index menuObject.Items.UpdateChanges(); i=1; } return true; }
This works for the case, where there are only default context menu items(ie; no X,Y). The LoadMoreData appears as the last item on each click and the functionality works fine. After that i changed the code. I removed the flag option(the 'i'), from the code so that the context menu binding does always. Now am able to get the context menu in each click, but with reduced items, or with weird items or something like that. Now check the code below, which is the one am using currently, where LoadMoreData appears as the first item default, and the rest of the context menu items.
function HandleRowContextMenu(controlId, rowType, rowElement, menuObject){ //==========Add Custom menu items to context menu===================// //View Menu var x = new WebMenuItem(); x.Text = 'X'; x.Name = "X"; x.ImageURL= "../CommonLibrary/Images/wg_view.gif" x.OnClick = "gotoX"; //Delete Menu var y = new WebMenuItem(); y.Text = Y'; y.Name = "Y"; y.ImageURL= "../CommonLibrary/Images/customer.gif" y.OnClick = "gotoY"; menuObject.Items.Add(x); menuObject.Items.Add(y); //==========Hide Context menu items===================// menuObject.Items[5].Hide(); menuObject.Items[6].Hide(); menuObject.Items[7].Hide(); menuObject.Items[30].Hide(); menuObject.Items[31].Hide(); menuObject.Items[34].Hide(); menuObject.Items[35].Hide(); return true; }
In short my requirement is very simple, i would like to move the default context menu items to the position i want. For eg: say i have got 2 items add, delete in the context menu, then i would like to get the LoadMoreData option as the third one or say second one. i would like to know the name of each default context menu items(like mnuLoadmore). Hope for a solution as early as possible.
Xedem,
Using SP1 installer or latest hotfixes should fix this issue. Also, i attached the modified sample to show what i suggested before. Hope this helps.
Regards,Handy
ok.thanks. By the way we have downloaded 2009 WebUI with SP1 and the result is positive. Thanks for the fix.
I was able to replicate this issue in here and have reported to our developer team. I will let you know asap when i got response from them. By the way, I suggested not to hide the Menu based on Index. It would be better if you use "GetNamedItem" method because when you moved a menu, some of menu position would be changed.
Am sorry. In fact i applied the option as you have suggested. ie; i used GetNamedItem method. But that was unsuccessful too. Later on i changed the code in different ways to make it work.This was the modified code. Anyway please let me know as soon as the issue is solved. The following is the original code.
var loadMoreItem = menuObject.Items.GetNamedItem("mnuLoadMore"); menuObject.Items.Move(loadMoreItem.Index, menuObject.Items.length - 1);
Hi Xedem,
The Move method of WebMenuItem has a known issue which caused items to be incorrectly positioned after the third call.
This issue has been fixed with bug# 366, and will be included in the upcoming service pack.
Hope this helps.
Oh!. I didnt check that. I will use SP1 as soon as possible and will reply.
hi
Am using WebUI 2008 R2. And i didnt see any Service pack release. All i could see was 2009 WebUI SP1.
So how am gonna resolve my problem? Am using Webgrid 6.0
Thank you for your confirmation. I have tested it and it seems the fix only on WebDesktop 3.0. We will also fix this in WebDesktop 2.5 and send it to you.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname