Hi,
We're using the 2008.1 release and have run into a problem where the positioning of the Popup Menu, when attached to the a Tree View, is incorrect. With a bit of analysis we can see that in Internet Explorer, the issue is due to the fact that the position is not taking into account the top and left margins of the page - we have a fixed margin of 10px at the top of the page and are using 'Margin: 0px auto 0px auto' to achieve centering. There are also problems in Firefox, but at the moment we have not understood the cause, however the positioning is more significantly incorrect and every time the popup menu is displayed by right clicking on the tree node it's width increases by a number of pixels.
Has anyone else experienced this issue? Is there something that we should be doing, but have missed?
For reference, we use the javascript below in other solutions to position popup help panels, etc for a given element successfully in both Firefox and Internet Explorer.
function FindElementsPosition(element) {
var curLeft = 0; var curTop = 0;
if (element.offsetParent) {
curLeft = element.offsetLeft curTop = element.offsetTop
while (element = element.offsetParent) { curLeft += element.offsetLeft curTop += element.offsetTop }
}
return [curLeft,curTop];
Thanks in advance....
Cheers, James.
Hello James,
Positioning in browsers is a very tricky topic, and there are various problems to deal with. The FindElementsPosition function you are using is a variation of the classic FindPos function first introduced by the Quirksmode web-site:
http://www.quirksmode.org/js/findpos.html
However, If you are already using ASP.NET 3.5 and/or ASP.NET AJAX, you can try using the not very popular, but very helpful client-side method getLocation to get the coordinates of the element clicked and place the menu there. Some information can be found here:
http://weblogs.asp.net/bleroy/archive/2008/01/29/getting-absolute-coordinates-from-a-dom-element.aspx
I am almost positive that the newly introduced function gives better results than the QuirksMode one. You can also take a look at the following blog post for comments/reflections and suggestions related to positioning and coordinates in browsers:
http://www.jtulloch.com/blog/post/2008/02/Mouse-position---relative-to-a-containing-element.aspx
Hope this helps.
Hi Rumen,
Thanks for the response, we are indeed familiar with the articles you've provided links to above. I guess the question we're asking, is should we be expecting the Popup Menu functionality to work correctly 'out of the box'? We can see that it works in the samples and the demonstration sites provided, but seems to fall down when margins are involved. Our development plans for the project asssume that the Infragistics toolkit provides the functionality we require as advertised and haven't considered at this stage that we need to be responsible for actually resolving positioning issues related in this case to Popup Menus attached to the UltraWebTree.
We need a steer as to whether we need to factor in this development into our schedule, or should be raising this as a bug with Infragistics. As far as the examples and documentation indicate, unless we are missing something, we should only need to add the following to achieve the functionality required;
if(button == 2) { var tree = igtree_getTreeById(treeId); igmenu_showMenu('UltraWebMenu1',tree.event) return true;}
I look forward to hearing from you.....