【问题标题】:How to change cell width in React Table如何更改 React Table 中的单元格宽度
【发布时间】:2021-11-22 16:20:12
【问题描述】:

我需要在使用 React Table 库时更改单元格宽度,但我对宽度更改的任何想法都失败了。我需要这样做以使“Użytkownik/Rola”列更接近,就在“Status”列附近。我不想使用负值的 margin-left 因为它通常不是推荐的解决方案。 通常呈现的宽度大于 style={{}} 中提供的宽度 这是它的实现方式:

{
            Header: useTranslactionFunc('Status'),
            accessor: 'status',
            width: 40,
            minWidth: 40,
            Cell: (props: CellValue) => (
                <div
                    style={{
                        display: 'flex',
                        alignItems: 'center',
                        justifyContent: 'flex-start',
                        marginLeft: '1.5rem',
                    }}
                >
                    {props.cell.value ? (
                        <PlayCircleOutlineIcon
                            style={{
                                color: theme.palette.success.main,
                            }}
                        />
                    ) : (
                        <NotInterestedIcon
                            style={{ color: theme.palette.error.main }}
                        />
                    )}
                </div>
            ),
        },

这里是如何渲染的:

【问题讨论】:

  • 你试过设置div的宽度、最大宽度和最小宽度吗?
  • 是的,不工作

标签: reactjs react-table


【解决方案1】:

我认为width 属性在使用表格布局时不适用。尝试使用useBlockLayout 钩子。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-06
    • 1970-01-01
    • 2021-05-22
    • 1970-01-01
    • 1970-01-01
    • 2017-10-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多