p-Table: scrollable columns with a min-width can not be resized
I'm submitting a ... (check one with "x")
[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Plunkr Case (Bug Reports)
https://stackblitz.com/edit/primeng-tablescroll-demo-dvms7k?file=src%2Fapp%2Fapp.component.html
Current behavior Having a scrollable table with min-widths (e.g. in px) prevents column resizing.
Expected behavior Columns should be resized with regards to the min-width.
Minimal reproduction of the problem with instructions
- See the above stackblitz
- Grab any column (perhaps one of the middle ones)
- release to the right
- no resizing occurs
I believe the problem comes from the following line (or is atleast a beginning): https://github.com/primefaces/primeng/blob/fbb4969156b40b2e94e1e73c61efb24780312820/src/app/components/table/table.ts#L1855 The min-width must have a unit ( => its a string) while the newColumnWidth is a number. Since the comparison between a number and a string is then always false, no resizing happens because the branch never gets executed.
What is the motivation / use case for changing the behavior? We need a scrollable table that scrolls when columns can not shrink any further. We also want the columns to be resizeable.
Please tell us about your environment:
-
Angular version: 12
-
PrimeNG version: 12.2.1
-
Browser: Chrome Version 92.0.4515.159
-
Language: TypeScript
-
Node (for AoT issues):
node --version= v14.15.4
Having the same problem here...
Same here, the migration was pretty painful. Actually not a bug, they switched to the flexbox model and ditched the colgroup as mentioned in their changelog notes (breaking changes if I'm not mistaken).
Therefore you've to go with the flex styles, if you are looking for fixed widths e.g. toggle button etc. just set flex 0 0 200px instead.
https://stackblitz.com/edit/primeng-tablescroll-demo-oaxrpu?file=src/app/app.component.html
I would add, that it is codewise still a bug. As you already noted about min-width:
The min-width must have a unit ( => its a string) while the newColumnWidth is a number. Since the comparison between a number and a string is then always false, no resizing happens because the branch never gets executed.
min-width needs a length as said here and here.
Therefore this code can not work. In any case (Nothing to do with scrollable etc.). In Version 13.1.0 this bug still exist: https://stackblitz.com/edit/primeng-tablecolresize-demo-sza6mz?file=src/app/app.component.html
https://github.com/primefaces/primeng/blob/master/src/app/components/table/table.ts#L1952
My suggestion to solve is a simple function accepting only px as css-unit for min-width. Removing the px from the unit and then continues the comparison of offset- and min-width.
@maertz Thank you for your interesting take. May solve my problem.
Same issue here.
Issue still persists in version 13.3.3.
Solution is not that trivial for any other than min-width with unit "px". em and rem would be doable, but as soon as we get to % it gets ugly.
I think the first workaround should be "Number.parseInt(minWidth)". This would at least work with px. The current state is broken to its bone as no valid min-width will work.
it seems min-width in inline css won't work, but if set in a stylesheet, then it'd work. i've modified the stackblitz as an example: https://stackblitz.com/edit/primeng-tablescroll-demo-okmmcf?file=src/app/app.component.css
where i removed the min-width from html:

and updated the corresponding css:

Hi,
So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap? Please don't forget to add your feedback as a comment after reopening the issue. These will be taken into account by us and will contribute to the development of this feature. Thanks a lot for your understanding!
Best Regards,