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

164
Visualizações
How to push dynamic columns and row data to antd table

enter image description here

The below code is not accepting for an array of rows and columns

Here is antd example:

const data = [];
for (let i = 0; i < 4; i++) {
  data.push({
    key: i,
    name: `Edward King ${i}`,
    age: 32
    //  address: `London, Park Lane no. ${i}`
  });
}

Tried same logic in below: 
// columns :datacloumns1
// rows :rowdata

const data = [];
for (let i = 0; i < 4; i++) {
   for (var j = 0; j < reportDataRows?.length; j++){
  data.push({
  datacloumns1[i]:rowdata[i] // here i am binding row to the exact column but this is not accepting
  });
}
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Thank you for your suggestions.

Here is the solution: have changed my result to title and dataIndex format, so I realized that antd table accepts only the title and dataIndex format.

let datacloumns = reportDataRows && Object.keys(reportDataRows[0])?.map((key) => (
    <span >{cloumns.push({
        title: key, dataIndex: key,
        //defaultSortOrder: 'descend',
        sorter: true
    })}
    </span>))

< Table 
  rowClassName = {(record, index) => index % 2 === 0 ? 'table-row-light' : 'table-row-dark'} 
  size = { 'default'} 
  columns = { cloumns } 
  bordered = { true} 
  sortDirections = { ['ascend', 'descend'] } 
  loading = { reportDataRows === undefined ? true : false} 
  pagination = {{ pageSize: 10 }} dataSource = { reportDataRows === undefined ? [] : reportDataRows} 
/>
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