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

186
Visualizações
How to search through dynamic table vuejs?

So I am creating tables in vue using loops, i.e. anyone can upload a table and view it.

<el-table :data="filtered"  border style="width: 100%" height="500" @selection-change="handleSelectionChange" @header-click="contextmenu">
  <el-table-column type="selection" width="55"/>
  <el-table-column  fixed v-for="col in columns" :prop="col.field" :label="col.field" :key="col.field"/>
  <el-table-column>
    <template #header>
        <el-input v-model="searchQuery" size="small" placeholder="Type to search" />
      </template>
      <template #default="scope">
        <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">Delete</el-button>
      </template>
    </el-table-column>
  
  </el-table>
  <el-button type="warning" round v-on:click="getdata(selected_data,source)">Update-Data</el-button>
</div>

I and trying to implement a search feature that is dynamic, i.e. it can search through all the columns of any table uploaded by user. I saw some solutions online but they are for fixed tables. I also tried writing a loop and returning the data

computed: {
    filtered (){
      if(this.searchQuery){
      return this.d.filter((item)=>{
        for(let i=0;i<this.columns.length;i++){
          const x=this.columns[0].field //I have an array columns which has all the columns inside 
                                          //of it in a dictionary
          console.log(item.x.startsWith(this.searchQuery)) //this gives an error *Cannot read 
                                                             //properties of undefined (reading 
                                                             //'startsWith')*
        }
        return item.Name.startsWith(this.searchQuery); // and this line works perfectly fine, if I  
                                                          //the table has a column named **Name**
      })
      }else{
        return this.d; //d is the data array
      }
    }
  }

Is there a way I can search through all the columns of any table uploaded by the user? Any suggestions are greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I solved it by using item[x] instead of item.x.

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