Daniel Obara
Daniel Obara

Reputation: 267

How to change name and Icon of Action Column in Material-Table React

I'm using Material Table and I need change the Action column name but this column is automatic generated because I'm using editable function from material table.

<MaterialTable
    title=""
    localization={{
      body: {
        editRow: {
          saveTooltip: "Salvar",
          cancelTooltip: "Cancelar",
          deleteText: "Tem certeza que deseja deletar este registro?"
        },
        addTooltip: "Adicionar",
        deleteTooltip: "Deletar",
        editTooltip: "Editar"
      }
    }}
    columns={state.columns}
    data={state.data}
    editable={{
      onRowAdd: newData => createInstructor(newData),
      onRowUpdate: async (newData, oldData) =>
        updateInstructor(newData, oldData),
      onRowDelete: oldData => deleteInstructor(oldData)
    }}
  />

How can I change these icons and column name ?

Upvotes: 13

Views: 12445

Answers (1)

jayarjo
jayarjo

Reputation: 16716

As you've rightfully assumed, the title of the that column, as well as all the text strings in the material table are customizable via localization property.

<MaterialTable
    // other props
    localization={{
        pagination: {
            labelDisplayedRows: '{from}-{to} of {count}'
        },
        toolbar: {
            nRowsSelected: '{0} row(s) selected'
        },
        header: {
            actions: 'Actions'
        },
        body: {
            emptyDataSourceMessage: 'No records to display',
            filterRow: {
                filterTooltip: 'Filter'
            }
        }
    }}
/>

Notice header.actions item. That's the one for you.

Upvotes: 18

Related Questions