Grid component not scalling properly

0 Answers 88 Views
Grid
Kamil
Top achievements
Rank 1
Iron
Iron
Kamil asked on 07 Dec 2022, 12:09 PM | edited on 07 Dec 2022, 12:29 PM
Hello,
grid component is not scalling properly when page zoom is less than 100%.

This can be reproduced here: https://codesandbox.io/s/pqwmz4 (default grid from documentation https://www.telerik.com/kendo-react-ui/components/grid/)

Change page zoom to 33%:


Result: blank space visible after last column
What i want to achievie: columns are fully scalled and blank space is not visible
Wissam
Telerik team
commented on 09 Dec 2022, 08:49 AM

Hi, Kamil,

Thank you for the provided screenshot.

The faced behavior is expected as in the linked Overview demo of the Grid we are setting a specific width for all the GridColumn components using the width prop, which will make them not stretch.

It is enough to have at least one column without set `width` (or with `width` set to `auto`) which will allow the column to stretch depending on the available white space. You can see that in the example of the getting started Grid article where only the `ProductID` and `ProductName` columns have a set width:

    For more information about customizing the width of the GridColumn, you can check the following article:

    I hope this helps, but please let me know if you have any further questions.

    Regards,
    Wissam
    Progress Telerik
    Kamil
    Top achievements
    Rank 1
    Iron
    Iron
    commented on 16 Dec 2022, 12:16 PM

    Hi Wissam, 
    thank you for your response. I tried your solution with not setting width to one of the columns and i ran into another problems.
    1. it works fine when changing scale to less than 100%, but when i scale page to some high value the column disappears
    2. it stops scalling when one of the columns was resized - after resize there is blank space like in the solution with all columns width set

    Regards, Kamil
    Wissam
    Telerik team
    commented on 19 Dec 2022, 12:25 PM

    Hello, Kamil,

    The column disappearing when zooming in can be resolved by setting a minimum column width. This approach is demonstrated in the below article, where a horizontal scrollbar will appear when the width of the Grid is smaller than the combined minimum width of all columns:

    Regarding the blank space when the column is resized, you can avoid this by setting the column width to `auto` instead of not setting it. In the below example, I set the width of the grid column with the `UnitsInStock` field to `auto`:

    I hope this helps, but please let us know if you have further questions.

    Regards,
    Wissam
    Progress Telerik
    Kamil
    Top achievements
    Rank 1
    Iron
    Iron
    commented on 23 Dec 2022, 01:05 PM | edited

    Hello Wissam,

    thank you for your response, it seems like 2nd solution doesnt work with locked column, add "locked" property to last column ( https://stackblitz.com/edit/react-agcqhv?file=app%2Fmain.jsx) and it dissapears when zoomed, even with minResizibleWidth set.

    not zoomed:


    zoomed and scrolled max to the right - locked column not visible:
     

    Konstantin Dikov
    Telerik team
    commented on 27 Dec 2022, 10:09 AM

    Hi Kamil,

    The locked column should have fixed width, even if it is the last column, because the "auto' will not work for it. If the last column is locked and you set a fixed width for it, you can set the "auto" to the last unlocked column. I have modified the example with that configuration:

    Hope this helps.

     

    Kamil
    Top achievements
    Rank 1
    Iron
    Iron
    commented on 27 Dec 2022, 02:37 PM | edited

    Hello Konstantin,
    thank you for your response, but in your solution now the last unlocked column is not visible when page is scalled up to 250%


    Google Chrome
    - scalled to 200% - all columns are visible
    - scalled to 250% and scrolled maximum to the right - "Price" column is not visible


    I want to achieve fully scalable grid without any columns disappearing, is that even possible?

    Konstantin Dikov
    Telerik team
    commented on 27 Dec 2022, 09:13 PM

    Due to the way that the browser's zoom work, in order for the Grid to keep the proportions, its width and height must be fixed. Since the width is set to fill the available width, when the browser is zoomed, that width will get smaller and the columns will shrink. You can see in the following example that putting fixed width for the Grid will keep the columns as per your requirement:

        <Grid
          style={{
            height: '400px',
            width: '800px',
          }}

    If you want to keep the width of the Grid "100%" (the default) you will have to ensure that the container element in which the Grid is positioned expands when the browser is zoomed.

    Hope this helps.

    Kamil
    Top achievements
    Rank 1
    Iron
    Iron
    commented on 02 Jan 2023, 12:21 PM | edited

    Hello Konstantin,
    i want to achievie 2 things in grid with 5 columns and last column is locked:

    1. Not locked column with width set to auto will never disappear when zoom is more than 100%
    2. There is no blank space in grid when 2nd column width is set to auto and user resize any of 4 columns [resize on last locked column is disabled].

    Are those 2 things possible to do? I tried so many combinations of grid settings and nothing worked to achievie this things together
    https://codesandbox.io/s/gallant-gauss-f910nr?file=/app/main.tsx
    Konstantin Dikov
    Telerik team
    commented on 03 Jan 2023, 12:26 PM

    Hello Kamil,

    As mentioned in my previous reply, if you want to keep the width of the columns while the browser is zoomed, you need to either set explicit width to the Grid or to handle the zoom event in the browser and manually expand the container where the Grid is rendered. We do not have any control over how the browser handles the zooming of table elements.

    As for the second question, this would be the default behavior if the 2nd column is not resized. If you resize a column with width set to "auto", it will receive a fixed width afterwards. To avoid this you can set the "resizable" property of that column to "false":

    <GridColumn field="ProductName" title="Name" width="auto" resizable={false} />

     

    No answers yet. Maybe you can help?

    Tags
    Grid
    Asked by
    Kamil
    Top achievements
    Rank 1
    Iron
    Iron
    Share this question
    or