-
Notifications
You must be signed in to change notification settings - Fork 158
Description
Description
Having columns with different minWidth causes the horizontal scrollbar to appear earlier than expected (when the grid's width is bigger than it should be).
<igx-grid
[data]="data"
[primaryKey]="'id'"
[autoGenerate]="false"
[height]="'300px'"
>
<igx-column [field]="'value'" [minWidth]="'100px'" [dataType]="'number'"></igx-column>
<igx-column [field]="'metric'" [minWidth]="'100px'" [dataType]="'number'"></igx-column>
<igx-column [field]="'status'" [minWidth]="'100px'" [dataType]="'string'"></igx-column>
</igx-grid>In the above, the columns have the same minWidth of 100px, so the grid's minimum width before the scrollbar appears should be 300px (100px+100px+100px).
When resizing the window, the grid reaches 300px and has no scrollbar. Then, when resizing a bit more so that the grid's width is below the minimum width, the scrollbar appears. This is the expected behavior.
However, if the minWidth is not the same for all columns, the total minimum width of the grid is not calculated as the sum of the individual column minWidth, but it applies the greatest minWidth for all columns and calculates the sum of that.
For example, in the below configuration, the total minimum width of the grid is again 300px (120px+90px+90px).
<igx-grid
[data]="data"
[primaryKey]="'id'"
[autoGenerate]="false"
[height]="'300px'"
>
<igx-column [field]="'value'" [minWidth]="'120px'" [dataType]="'number'"></igx-column>
<igx-column [field]="'metric'" [minWidth]="'90px'" [dataType]="'number'"></igx-column>
<igx-column [field]="'status'" [minWidth]="'90px'" [dataType]="'string'"></igx-column>
</igx-grid>However, the grid takes the greatest minWidth (120px) and applies it to all columns when calculating the minimum width (3x120px = 360px).
Another example:
<igx-grid
[data]="data"
[primaryKey]="'id'"
[autoGenerate]="false"
[height]="'300px'"
>
<igx-column [field]="'value'" [minWidth]="'80px'" [dataType]="'number'"></igx-column>
<igx-column [field]="'metric'" [minWidth]="'90px'" [dataType]="'number'"></igx-column>
<igx-column [field]="'status'" [minWidth]="'130px'" [dataType]="'string'"></igx-column>
</igx-grid>
This does not prevent the columns from sizing to their designated minimum widths, but the window should be resized to be even smaller, and the scrollbar's scroll area gets bigger.
If not all columns have minWidth set, the default 136px value is used for the particular column. The below will set 136px as the minimum width for all columns when calculating the grid's minimum width, since 136px is greater than the other values.
<igx-grid
[data]="data"
[primaryKey]="'id'"
[autoGenerate]="false"
[height]="'300px'"
>
<igx-column [field]="'value'" [minWidth]="'80px'" [dataType]="'number'"></igx-column>
<igx-column [field]="'metric'" [minWidth]="'90px'" [dataType]="'number'"></igx-column>
<igx-column [field]="'status'" [dataType]="'string'"></igx-column>
</igx-grid>- igniteui-angular version: 20.1.x, 21.0.x, master
- browser: any
Steps to reproduce
- Use any of the above configurations, resize the browser window, and observe the columns.
Result
The horizontal scrollbar appears earlier than expected, when the grid's width should be wide enough to display all the columns.
Expected result
Same behavior when all the minWidth values are the same. The horizontal scrollbar should not appear when the grid is wide enough to display all columns.