DataTable: fixed column width in px

UI Components for React
Post Reply
softsize
Posts: 8
Joined: 14 Jan 2017, 19:07

16 May 2023, 15:33

Hi
how i can set che column width in px as for version 6.6 (style={width:'100px'})?
new documentation is not clear for this... and the minWidth properties create conflict with resize of the column.

thanks

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

16 May 2023, 16:28

Working in PR 9.4.0 with reproducer: https://stackblitz.com/edit/react-poccy ... c%2FApp.js

so most likely a bug in 6.6.0 that has since been fixed.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

softsize
Posts: 8
Joined: 14 Jan 2017, 19:07

17 May 2023, 15:13

Melloware wrote:
16 May 2023, 16:28
Working in PR 9.4.0 with reproducer: https://stackblitz.com/edit/react-poccy ... c%2FApp.js

so most likely a bug in 6.6.0 that has since been fixed.
Thanks for the example and fast response.

i did a test adding properties to save state of table in sessionstorage (same as my case but i did it manually) in your example:

Code: Select all

stateStorage="session" 
stateKey="dt-state-demo-local"
and after enlarge all fields in different size and then refresh, this new size is not mantained after reload... also the sessionstorage data are different from the
state saved previous reload...
i think this is the problem that somehow affect my datatable that non reset the correct width after reload.

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

17 May 2023, 17:11

PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

softsize
Posts: 8
Joined: 14 Jan 2017, 19:07

18 May 2023, 08:23

Melloware wrote:
17 May 2023, 17:11
This might be your issue: https://github.com/primefaces/primereact/issues/4211 ??
the issue is different, because i reconstruct datatable with dynamic column and the width setted in column creation, but i think
that the origin of both issues might be the same...

softsize
Posts: 8
Joined: 14 Jan 2017, 19:07

18 May 2023, 11:30

softsize wrote:
18 May 2023, 08:23
Melloware wrote:
17 May 2023, 17:11
This might be your issue: https://github.com/primefaces/primereact/issues/4211 ??
the issue is different, because i reconstruct datatable with dynamic column and the width setted in column creation, but i think
that the origin of both issues might be the same...
i tryed to reproduce the problem:
https://stackblitz.com/edit/react-poccy ... src/App.js
if you enlarge the fields untile hscroll appeared and reload content, datatable graphically don't have the correct width (often all column has the same size) and the scrollbar disappeared
although inspecting html element the width is effectively correct as setted

softsize
Posts: 8
Joined: 14 Jan 2017, 19:07

18 May 2023, 12:37

Image

softsize
Posts: 8
Joined: 14 Jan 2017, 19:07

18 May 2023, 17:55

softsize wrote:
18 May 2023, 12:37
Image
Furthermore, continuing to test for solution, the "autolayout" and width don't work even in non resizable table if there are many columns as:

https://stackblitz.com/edit/react-pocc ... rc/App.js
columns are all tight and same sized...
if i set resizable={true}, "autolayout" magically work.

softsize
Posts: 8
Joined: 14 Jan 2017, 19:07

19 May 2023, 14:58

solved with:

Code: Select all

tableStyle={{tableLayout:'fixed'}}
property in DataTable

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests