如何为 "material-table" 中的替代行添加 rowStyle?
How to add rowStyle for alternative rows in "material-table"?
I want to apply rowstyles alternative rows in material-table
我希望你指的是这个material-table,如果是的话你可以使用rowStyle
。
<MaterialTable
title="Row Styling Preview"
columns={[
{ title: 'Name', field: 'name' },
{ title: 'Surname', field: 'surname' },
{ title: 'Birth Year', field: 'birthYear', type: 'numeric' },
{
title: 'Birth Place',
field: 'birthCity',
lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
},
]}
data={[
{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
]}
options={{
rowStyle: x => {
if (x.tableData.id % 2) {
return {backgroundColor: "lightgreen"}
}
}
}}
/>
I want to apply rowstyles alternative rows in material-table
我希望你指的是这个material-table,如果是的话你可以使用rowStyle
。
<MaterialTable
title="Row Styling Preview"
columns={[
{ title: 'Name', field: 'name' },
{ title: 'Surname', field: 'surname' },
{ title: 'Birth Year', field: 'birthYear', type: 'numeric' },
{
title: 'Birth Place',
field: 'birthCity',
lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' },
},
]}
data={[
{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
{ name: 'Zerya Betül', surname: 'Baran', birthYear: 2017, birthCity: 34 },
]}
options={{
rowStyle: x => {
if (x.tableData.id % 2) {
return {backgroundColor: "lightgreen"}
}
}
}}
/>