Skip to content

Conversation

amanmahajan7
Copy link
Collaborator

@amanmahajan7 amanmahajan7 commented Feb 22, 2022

Column now supports CSS grid units including auto (default), fr, %, max-content etc. To handle virtualization, a flex column is assigned a width of (80px) and the actual width is calculated after the grid is rendered.

@amanmahajan7 amanmahajan7 self-assigned this Feb 22, 2022
@codecov
Copy link

codecov bot commented Feb 22, 2022

Codecov Report

Merging #2839 (151d724) into main (dd90693) will increase coverage by 0.32%.
The diff coverage is 95.23%.

❗ Current head 151d724 differs from pull request most recent head edc46e7. Consider uploading reports for the commit edc46e7 to get more accurate results

@@            Coverage Diff             @@
##             main    #2839      +/-   ##
==========================================
+ Coverage   94.02%   94.35%   +0.32%     
==========================================
  Files          38       38              
  Lines        1256     1258       +2     
  Branches      403      405       +2     
==========================================
+ Hits         1181     1187       +6     
+ Misses         75       71       -4     
Impacted Files Coverage Δ
src/HeaderCell.tsx 90.00% <0.00%> (ø)
src/HeaderRow.tsx 100.00% <ø> (ø)
src/style/cell.ts 100.00% <ø> (ø)
src/DataGrid.tsx 91.26% <95.00%> (+0.84%) ⬆️
src/hooks/useCalculatedColumns.ts 100.00% <100.00%> (+0.83%) ⬆️
src/hooks/useGridDimensions.ts 100.00% <100.00%> (ø)
src/hooks/useViewportColumns.ts 85.71% <100.00%> (+2.85%) ⬆️

@amanmahajan7 amanmahajan7 changed the title Feature: Add "auto" column width Feature: Add support for flex column width Mar 15, 2022
@amanmahajan7 amanmahajan7 marked this pull request as ready for review March 15, 2022 18:34
@amanmahajan7 amanmahajan7 requested a review from nstepien as a code owner March 15, 2022 18:34
left: number;
}

const DEFAULT_COLUMN_WIDTH = 'auto';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before
image

After
image

if (typeof width === 'number') {
return width;
}
if (typeof width === 'string' && /^\d+%$/.test(width)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed as we get the width after the columns are rendered

@amanmahajan7 amanmahajan7 mentioned this pull request Mar 16, 2022
amanmahajan7 and others added 7 commits September 16, 2022 11:25
Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>
Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>
@amanmahajan7 amanmahajan7 merged commit 4a136ad into main Sep 16, 2022
@amanmahajan7 amanmahajan7 deleted the am-auto-columns branch September 16, 2022 17:29
keriat pushed a commit to superform-xyz/react-data-grid that referenced this pull request Jan 10, 2024
## [5.1.0](v5.0.4...5.1.0) (2024-01-10)

### Features

* Add DataGridComponentsProvider component and DataGrid.components prop ([Comcast#2754](https://github.com/superform-xyz/react-data-grid/issues/2754)) ([f864291](f864291))
* Add support for flex column width ([Comcast#2839](https://github.com/superform-xyz/react-data-grid/issues/2839)) ([4a136ad](4a136ad))
* expose scroll event ([Comcast#2011](https://github.com/superform-xyz/react-data-grid/issues/2011)) ([7614c8e](7614c8e))
* RTL ([Comcast#2803](https://github.com/superform-xyz/react-data-grid/issues/2803)) ([c0e4a63](c0e4a63))
* semantic release installed and configured ([e71bfe6](e71bfe6))

### Bug Fixes

* drag jumps to the right due to the failed merge ([Comcast#1564](https://github.com/superform-xyz/react-data-grid/issues/1564)) ([7033a1b](7033a1b))
* isSelectedCellEditable row getter idx ([Comcast#1743](https://github.com/superform-xyz/react-data-grid/issues/1743)) ([018f137](018f137))
* package-lock.json added to version control ([df39113](df39113))

### Reverts

* Revert "Dependabot: set versioning-strategy to increase (Comcast#2479)" (Comcast#2511) ([0bedc81](0bedc81))
keriat pushed a commit to superform-xyz/react-data-grid that referenced this pull request Jan 10, 2024
## [5.1.0](v5.0.4...5.1.0) (2024-01-10)

### Features

* Add DataGridComponentsProvider component and DataGrid.components prop ([Comcast#2754](https://github.com/superform-xyz/react-data-grid/issues/2754)) ([f864291](f864291))
* Add support for flex column width ([Comcast#2839](https://github.com/superform-xyz/react-data-grid/issues/2839)) ([4a136ad](4a136ad))
* expose scroll event ([Comcast#2011](https://github.com/superform-xyz/react-data-grid/issues/2011)) ([7614c8e](7614c8e))
* RTL ([Comcast#2803](https://github.com/superform-xyz/react-data-grid/issues/2803)) ([c0e4a63](c0e4a63))
* semantic release installed and configured ([e71bfe6](e71bfe6))

### Bug Fixes

* drag jumps to the right due to the failed merge ([Comcast#1564](https://github.com/superform-xyz/react-data-grid/issues/1564)) ([7033a1b](7033a1b))
* isSelectedCellEditable row getter idx ([Comcast#1743](https://github.com/superform-xyz/react-data-grid/issues/1743)) ([018f137](018f137))
* package-lock.json added to version control ([df39113](df39113))

### Reverts

* Revert "Dependabot: set versioning-strategy to increase (Comcast#2479)" (Comcast#2511) ([0bedc81](0bedc81))
adityatoshniwal pushed a commit to pgadmin-org/react-data-grid that referenced this pull request Jul 31, 2024
* Add support for "auto" width

* Calculate columns when grid width is set

* Remove unnecessary code

* Add support for css column units (fr, %, max-content)

* Bring back virtualization

* Remove console

* Fix minWidth and examples

* Add min width

* Disable @typescript-eslint/naming-convention

* Add comments

* Revent some changes

* Use getBoundingClientRect

* Rename variables

* support flex width on all the columns

* Fix tests

* Update src/DataGrid.tsx

Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>

* Address a few comments

* Move width type close to minWidth

* Do not reset max-content columns

* Remove flexColumnWidths state

* Add max-content example

* Update src/DataGrid.tsx

Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>

* Fix classname

* Update src/hooks/useGridDimensions.ts

Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>

* Remove useMemo

* Add back useMemo

* tweak autosizeColumnsClassname for better measuring

* Revert "tweak autosizeColumnsClassname for better measuring"

This reverts commit 151d724.

Co-authored-by: Aman Mahajan <amahajan@freewheel.tv>
Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>
Co-authored-by: Nicolas Stepien <stepien.nicolas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants