Is there a built in way to make the detail grid sticky (scrolls horizontally with the user and not take up the entire width of the grid)

1 Answer 62 Views
Grid GridLayout Styling Styling / Themes
Jonathon
Top achievements
Rank 1
Jonathon asked on 16 Dec 2024, 08:28 PM

In our grid we are providing an expansion field and providing a detail grid as given in the Master-Detail grid example:
React Data Grid Master-Detail Grids - KendoReact

In all of the examples the detail grid takes up the entire width of the main grid. I can limit the detail grid to be the screen size and align it to the left of the master grid, but I am having difficulty having the grid be sticky within the master grid. (here is an example from MUI Data Grid - Master detail - MUI X

I have tried making the inner div
position: sticky;
width: 90vw;
left: 5vw


but it does not scroll within the grid. Am I missing something easy?

Jonathon
Top achievements
Rank 1
commented on 17 Dec 2024, 02:56 PM | edited

So I found a terrible disgusting hack for how to make this work.

wrapping the detail grid I added:

<div
            style={{ height: (rowHeight * maxRows + 30).toString() + "px" }}
            className={searchGridDetailCSS.detailGridContainer}
        >
            <div
                style={{
                    position: "absolute",
                    top: (props.dataIndex * rowHeight  + 45).toString() + "px",
                    width: "90vw",
                    left: "5vw",
                }}
                className={`${flex.flexRow} ${flex.gap}`}
            >

Then I can override the relative position of every row and container for the grid until I get to one container outside of the grid. This sticks.

But calculating the expansion panels size and placing the dropdowns within it, seems wrong. Also this solution only works if the height of the main grid is static. (in my case it was, but that may not always be true. As in if the grid sits in a Y scrollable div, the absolute position will not scroll vertically with the grid, breaking this solution)

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 19 Dec 2024, 03:58 PM

Hi, Jonathon,

Thank you for letting us know that your query is resolved. As for the requested alternative solution, you can consider calculating the width of the detailed grid by extracting the width of its surrounding elements with a similar CSS style:

            .k-detail-grid-wrapper {
                display: flex;
                flex-direction: column;
                width: calc(100% - (32px + 24px + 365px + 200px));
            }

or by directly passing the desired percentage size to it:

            .k-detail-cell .k-grid {
                position: sticky;
                top: 0;
                width: 70vw;
                left: 5vw;
                background-color: white;
                z-index: 1;
            }

Kind regards,
Vessy
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid GridLayout Styling Styling / Themes
Asked by
Jonathon
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or