You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a table with editable cells, one of which contains a dropdown. When a user chooses something in that dropdown, it expands to fit that content.
Is there any way to resize the entire column to the width of that cell (or the largest cell?)
I tried useFlexLayout, and the body resizes but not the header.
This is what I am doing right now, or have started doing, and I wanted to make sure I am on the right track
// In Table Component
const [coursesWidth, setCoursesWidth] = useState(200);
const columns = useMemo(() => tableColumns(coursesWidth), [coursesWidth]);
const { ... } = useTable({setCoursesWidth}, ...)
// Colums.tsx
export const tableColumns = (coursesWidth: number): Array<Column<RowDataProps>> => [
{
Header: 'Course',
accessor: 'course',
minWidth: coursesWidth,
Cell: ({
setCoursesWidth,
}): ReactNode => {
// sudocode
// use a ref to measure the size of the dropdown and then do
if (dropdownWidth > coursesWidth) {
setCoursesWidth(drowdownRef.width);
}
}
}
]
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi!
I have a table with editable cells, one of which contains a dropdown. When a user chooses something in that dropdown, it expands to fit that content.
Is there any way to resize the entire column to the width of that cell (or the largest cell?)
I tried useFlexLayout, and the body resizes but not the header.
This is what I am doing right now, or have started doing, and I wanted to make sure I am on the right track
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions