Skip to main content

ASPxClientMenuCollection.RecalculateAll Method

Recalculates the position of visible sub menus.

#Declaration

TypeScript
RecalculateAll(): void

#Remarks

The position of the invoked submenu is calculated relative to the main menu position. If the main menu position is changed (for example, by applying specific style settings) while a certain submenu is being invoked, the invoked submenu position will not be changed. Use the RecalculateAll method to recalculate the new position of the invoked submenu.

#Example

This example demonstrates how to recalculate a new position of the invoked submenu if the position of the main menu has been changed.

<script type="text/javascript">
    const fixedStyleName = 'fixed_style';
    var menuBar = document.getElementById('menu_container'),
        menuBarOffsetTop = menuBar.offsetTop;
    function Recalculate() {
        if(enableRecalculate.GetChecked())
            ASPxClientMenuBase.GetMenuCollection().RecalculateAll();
    }    
    window.addEventListener('scroll', function() {
        if(window.scrollY > menuBarOffsetTop && !menuBar.classList.contains(fixedStyleName)) {
            menuBar.classList.add(fixedStyleName);
            Recalculate();
        }
        else if(window.scrollY <= menuBarOffsetTop && menuBar.classList.contains(fixedStyleName)) {
            menuBar.classList.remove(fixedStyleName);
            Recalculate();
        }
    });
</script>
See Also