有没有办法使用 Material Table React 将 <label></label> 添加到每一列 header
is there a way to add a <label></label> to every column header using Material Table React
您好,我正在尝试向 table 的每个单元格添加一个 <label></label>
。我在这里使用 Material table:https://material-table.com/#/docs/features/component-overriding
我这样试过:
<Table
onChangePage={handleChangePage}
page={props.currentPage}
totalCount={props.totalCount}
options={{
paging:true,
pageSizeOptions:[10, 15, 25, 50],
pageSize: props.rowsPerPage,
padding: "dense",
search: false,
toolbar:false,
headerStyle: TableHeaderRow, <--- cssproperties
rowStyle:TableRow <--- cssproperties
}}
columns={columns} <--- variable columns:TableColumn[]
data={dataAct} <---- data generated from API
/>
其实我在options里面定义了headerStyle
,但是我真正想要的是加一个
<label>
headerValueHere}
</label>
每 header.
我在单元格中添加了 label 标签,就像在定义列中使用 render 一样:
const getDocumentTypeForRow = rowData => {
return (
<Tooltip title={rowData}>
<label style={OpenVulnerabilityDuePatchingCardDetailsElementLabel}>
{rowData}
</label>
</Tooltip>
)
};
const columns: TableColumn<>[] = [
{
title: 'Due Date',
field: 'remediation_due_date',
render: data => getDocumentTypeForRow(data.remediation_due_date)
},
]
但是如何做到 header 秒???
您可以将 JSX 或 HTML 传递给标题
const columns: TableColumn<>[] = [
{
title: <label>Due Date</label>,
field: 'remediation_due_date',
render: data => getDocumentTypeForRow(data.remediation_due_date)
},
]
您可以在此处进行实时编辑并查看结果
https://material-table.com/#/docs/features/styling
columns={[
{
title: <h1>Heading 1</h1>, field: 'name',
cellStyle: {
backgroundColor: '#039be5',
color: '#FFF'
},
headerStyle: {
backgroundColor: '#039be5',
}
},
{ title: 'Surname', field: 'surname' },
{ title: 'Birth Year', field: 'birthYear', type: 'numeric' },
{
title: 'Birth Place',
field: 'birthCity',
lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
},
]}
您好,我正在尝试向 table 的每个单元格添加一个 <label></label>
。我在这里使用 Material table:https://material-table.com/#/docs/features/component-overriding
我这样试过:
<Table
onChangePage={handleChangePage}
page={props.currentPage}
totalCount={props.totalCount}
options={{
paging:true,
pageSizeOptions:[10, 15, 25, 50],
pageSize: props.rowsPerPage,
padding: "dense",
search: false,
toolbar:false,
headerStyle: TableHeaderRow, <--- cssproperties
rowStyle:TableRow <--- cssproperties
}}
columns={columns} <--- variable columns:TableColumn[]
data={dataAct} <---- data generated from API
/>
其实我在options里面定义了headerStyle
,但是我真正想要的是加一个
<label>
headerValueHere}
</label>
每 header.
我在单元格中添加了 label 标签,就像在定义列中使用 render 一样:
const getDocumentTypeForRow = rowData => {
return (
<Tooltip title={rowData}>
<label style={OpenVulnerabilityDuePatchingCardDetailsElementLabel}>
{rowData}
</label>
</Tooltip>
)
};
const columns: TableColumn<>[] = [
{
title: 'Due Date',
field: 'remediation_due_date',
render: data => getDocumentTypeForRow(data.remediation_due_date)
},
]
但是如何做到 header 秒???
您可以将 JSX 或 HTML 传递给标题
const columns: TableColumn<>[] = [
{
title: <label>Due Date</label>,
field: 'remediation_due_date',
render: data => getDocumentTypeForRow(data.remediation_due_date)
},
]
您可以在此处进行实时编辑并查看结果
https://material-table.com/#/docs/features/styling
columns={[
{
title: <h1>Heading 1</h1>, field: 'name',
cellStyle: {
backgroundColor: '#039be5',
color: '#FFF'
},
headerStyle: {
backgroundColor: '#039be5',
}
},
{ title: 'Surname', field: 'surname' },
{ title: 'Birth Year', field: 'birthYear', type: 'numeric' },
{
title: 'Birth Place',
field: 'birthCity',
lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
},
]}