简体   繁体   English

如何使用 Material-table 更改索引列

[英]How can I change the index column using Material-table

Im using Material-table and I need to alter column index to put at the end of table because by default this column (actions) it is in the beginning.我使用材料表,我需要更改列索引以放在表的末尾,因为默认情况下,此列(操作)位于开头。

Below the table code:表格代码下方:

 <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)
    }}
  />

There's a dedicated option actionsColumnIndex :有一个专用选项actionsColumnIndex

actionsColumnIndex number 0 - Order of actions column actionsColumnIndex number 0 - 操作列的顺序

In order to make your actions column the last, assign a value of -1 to it.为了使您的操作列位于最后,请为其分配值-1

Use options with property actionsColumnIndex .使用带有属性actionsColumnIndexoptions The default value is 0. It means that it always locate at first columns.默认值为 0。这意味着它始终位于第一列。

If you want to move it to last column.如果要将其移至最后一列。 Just simply do:只需执行以下操作:

<MaterialTable
   options={{
      actionsColumnIndex: -1
   }}
/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM