-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to autosize column width to content? #525
Comments
Unfortunately we don't provide anything out of the box. You could conceivably implement this yourself and plug in to FDT though. You could approach it 2 ways depending on an accuracy / performance trade-off. Approach 1: Approach 2: This approach would be similar to React Virtualized's CellMeasurer. |
I was debating about 2 different approaches where the consumer calculates this: Approach 1 (calculate ahead of time and keep up to date): Approach 2 (calculate on demand): Thoughts? |
@Tanner-MS , thanks for you suggestions. A couple questions:
Is the One advantage of customizing the
Same reasoning as above. We can have the user pass in a double click handler which uses the consumer to calculate the max content width on the fly. |
maxContent width would be different than maxWidth. Max content is the widest width your value content would reach, max width is the largest the cell can go. Assuming this is the largest you can resize to as well. Also for this functionality you only want the double click on the resizer, not anywhere else in the header cell. While the user could parse this out based on the target of the event.
Guess same reason as having this built in makes it simpler on the consumer. They wouldnt have to query the target of the double click. |
Apologies for the confusion; I meant to use
Good points
Definitely. Passing a generic double click handler that targets just the resizer sounds like a better idea, maybe something like Also as a side note: In the v2.0-beta branch, we've moved out the resizing functionality from the main table component to a separate plugin based cell component. Also, since these plugins are decoupled out of the table component, we could even have a new plugin that contains business logic to compute the actual max content width. |
I'm looking for a way to size a column to fit the longest possible content rendered in that cell. So for example, if all rows would render content of 100px for this column, the column would be 100px wide -- but if one row renders 200px of content, the column would be 200px wide.
Is there a way to do that?
The text was updated successfully, but these errors were encountered: