In Development
Last Updated: 30 Apr 2025 14:43 by ADMIN
Scheduled for 2025 Q2 (May)
Hannes
Created on: 27 Oct 2021 08:09
Category: Grid
Type: Bug Report
2
Grid border misalignment after browser zoom change

Hello,

The Grid header and data cells become misaligned if the user changes the page zoom level. The right padding of the Grid header area resizes, according to the zoom level, but the scrollbar width remains the same. This triggers the misalignment.

The problem disappears after browser refresh at the current zoom level.

1 comment
ADMIN
Dimo
Posted on: 06 Oct 2023 07:00

Everyone who is experiencing this - a possible workaround is to recalculate and reset the Grid scrollbar width after page zoom change.

Place the following code in a JavaScript file that is loaded in your app (do not add it to a .razor file):

        window.addEventListener("resize", resetScrollbarWidth);

        function resetScrollbarWidth() {
            const scrollbarSize = getScrollBarSize();

            setCssVariable("--kendo-scrollbar-width", `${scrollbarSize.width}px`);
            setCssVariable("--kendo-scrollbar-height", `${scrollbarSize.height}px`);
        }

        function getScrollBarSize() {
            const outer = document.createElement('div');
            outer.style.visibility = 'hidden';
            outer.style.overflow = 'scroll';
            document.body.appendChild(outer);

            const inner = document.createElement('div');
            outer.appendChild(inner);

            const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
            const scrollbarHeight = outer.offsetHeight - inner.offsetHeight;

            outer.parentNode.removeChild(outer);

            return {
                width: scrollbarWidth,
                height: scrollbarHeight
            };
        };

        function setCssVariable(name, value) {
            const documentElement = document.documentElement;

            if (!documentElement) {
                return;
            }

            documentElement.style.setProperty(name, value);
        };