I am using a context menu as a "drop down button" where I tell the menu to showAt() a specific position. The problem is that if the menu is close to the bottom of the page, it will ignore my y coordinate and display itself further up the page (still keeping the x coordinate I supplied). It appears to be doing this in order to make sure the entire menu is visible in the window. Is there a setting or anything to prevent this behavior? I would like it to display where I tell it to...even if it expands the page downward.
| function showContextMenu(e,controlId,menuId){ |
| var control = document.getElementById(controlId); |
| var contextMenu = $find(menuId); |
| var pos; |
| pos = getControlPosition(controlId); |
| contextMenu.showAt((pos.x + control.offsetWidth), (pos.y)); |
| $telerik.cancelRawEvent(e); |
| } |
| function getControlPosition(elementId) { |
| var element = document.getElementById(elementId); |
| var left = 0; |
| var top = 0; |
| if (element != null) |
| { |
| // Try because sometimes errors on offsetParent after DOM changes. |
| try |
| { |
| do { |
| element = element.offsetParent; |
| left += element.offsetLeft; |
| top += element.offsetTop; |
| if (element != document.body && element != document.documentElement){ |
| top -= element.scrollTop; |
| left -= element.scrollLeft; |
| } |
| if(element.style.overflow != '' || element.style.overflowX != '' || element.style.overflowY != ''){break;} |
| } while(element.tagName!='BODY'); |
| } |
| catch (e) |
| { |
| // Do nothing |
| alert('error'); |
| } |
| } |
| return {x:left, y:top}; |
| } |