Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
Overriding add row function in material table

I want to execute a function before the add row editable opens. enter image description here Before this UI opens up I want to execute a function. (like console.log('Hello')) This is my current material table code.

            <MaterialTable
                title="Timesheet"
                columns={columns}
                data={DataArray}
                icons={tableIcons}
                editable={{
                onRowAddCancelled: rowData => console.log('Row adding cancelled'),
                onRowUpdateCancelled: rowData => console.log('Row editing cancelled'),
                onRowAdd: newData =>
                    new Promise((resolve, reject) => {
                        
                        setTimeout(() => {
                            // add row
                        }, 1000);
                    }),    

                }}
                options={{
                    actionsColumnIndex: -1,
                    addRowPosition: "first",
                    search:false,
                    exportButton: true,
                    
                }}
                
            />
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can put the code you want to execute in the onRowAdd callback function, for example

    <MaterialTable
      title="Timesheet"
      columns={columns}
      data={DataArray}
      icons={tableIcons}
      editable={{
        onRowAddCancelled: rowData => console.log('Row adding cancelled'),
        onRowUpdateCancelled: rowData => console.log('Row editing cancelled'),
        onRowAdd: newData => {
            console.log('Hello');
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    // add row
                }, 1000);
            });  
        }
      }}
      options={{
        actionsColumnIndex: -1,
        addRowPosition: "first",
        search:false,
        exportButton: true,
      }}
    />
  );

If you want to call your function on the + button click, you need to add the actions. For example

    <MaterialTable      
      actions={[
        {
          icon: 'add',
          tooltip: 'Add User',
          isFreeAction: true,
          onClick: (event) => alert("You want to add a new row")
        }
      ]}
    />
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda