如何使用 Material-table 更改索引列
How can I change the index column using Material-table
我正在使用 Material-table,我需要更改列索引以放在 table 的末尾,因为默认情况下此列(操作)位于开头。
table代码下方:
<MaterialTable
title=""
icons={tableIcons}
localization={{
body: {
editRow: {
saveTooltip: "Salvar",
cancelTooltip: "Cancelar",
deleteText: "Tem certeza que deseja deletar este registro?"
},
addTooltip: "Adicionar",
deleteTooltip: "Deletar",
editTooltip: "Editar"
},
header: {
actions: "Ações"
}
}}
columns={state.columns}
data={state.data}
editable={{
onRowAdd: newData => createInstructor(newData),
onRowUpdate: async (newData, oldData) =>
updateInstructor(newData, oldData),
onRowDelete: oldData => deleteInstructor(oldData)
}}
/>
有一个专用选项actionsColumnIndex:
actionsColumnIndex number 0 - Order of actions column
为了使您的操作列位于最后,请为其分配值 -1
。
将 options
与 属性 actionsColumnIndex
结合使用。默认值为0。表示它总是位于第一列。
如果你想把它移到最后一列。只需简单地做:
<MaterialTable
options={{
actionsColumnIndex: -1
}}
/>
我正在使用 Material-table,我需要更改列索引以放在 table 的末尾,因为默认情况下此列(操作)位于开头。
table代码下方:
<MaterialTable
title=""
icons={tableIcons}
localization={{
body: {
editRow: {
saveTooltip: "Salvar",
cancelTooltip: "Cancelar",
deleteText: "Tem certeza que deseja deletar este registro?"
},
addTooltip: "Adicionar",
deleteTooltip: "Deletar",
editTooltip: "Editar"
},
header: {
actions: "Ações"
}
}}
columns={state.columns}
data={state.data}
editable={{
onRowAdd: newData => createInstructor(newData),
onRowUpdate: async (newData, oldData) =>
updateInstructor(newData, oldData),
onRowDelete: oldData => deleteInstructor(oldData)
}}
/>
有一个专用选项actionsColumnIndex:
actionsColumnIndex number 0 - Order of actions column
为了使您的操作列位于最后,请为其分配值 -1
。
将 options
与 属性 actionsColumnIndex
结合使用。默认值为0。表示它总是位于第一列。
如果你想把它移到最后一列。只需简单地做:
<MaterialTable
options={{
actionsColumnIndex: -1
}}
/>