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

Context Menu Postion (Near Page Bottom)

6 Answers 55 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Dave Myers
Top achievements
Rank 1
Dave Myers asked on 09 Mar 2009, 08:54 PM
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}; 
        }  

6 Answers, 1 is accepted

Sort by
0
Dave Myers
Top achievements
Rank 1
answered on 10 Mar 2009, 01:41 PM
I also noticed the problem is amplified when the browser window is scrollable (the menu displays itself further up the page).
0
Accepted
Yana
Telerik team
answered on 11 Mar 2009, 02:21 PM
Hello Dave,

You should set EnableScreenBoundaryDetection property of the menu to false in order to prevent this behavior.

All the best,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dave Myers
Top achievements
Rank 1
answered on 11 Mar 2009, 05:39 PM
I was thinking/hoping it would be something this simple.  By the way, I couldn't find a list of properties & methods in the help documentation (desktop).
0
Veselin Vasilev
Telerik team
answered on 12 Mar 2009, 09:46 AM
Hello Dave Myers,

There should be a CHM file called:
telerik.aspnetajax.radcontrols.api.[VERSION].chm

which contains the API reference.

It can be accessed online as well.

Sincerely yours,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Suraj
Top achievements
Rank 1
answered on 08 Apr 2009, 08:29 PM
This will not work in case the page in an Iframe and specially if that iframe page is opened as modal dailog. Any suggestions?
0
Yana
Telerik team
answered on 13 Apr 2009, 10:58 AM
Hi Suraj,

It's supposed to work in an iframe. Could you please prepare a simple working example illustrating the issue and send it to us? You should open a support ticket in order to be able to attach files.

All the best,
Yana
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Menu
Asked by
Dave Myers
Top achievements
Rank 1
Answers by
Dave Myers
Top achievements
Rank 1
Yana
Telerik team
Veselin Vasilev
Telerik team
Suraj
Top achievements
Rank 1
Share this question
or