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

170
Visualizações
Autocomplete Search Via Another Paramter

In below example , -

https://codesandbox.io/s/g5ucdj?file=/demo.tsx

I want to achieve functionality such that , If I have array -

const top100Films = [
  { title: 'The Shawshank Redemption', year: 1994 },
  { title: 'The Godfather', year: 1972 },
  { title: 'The Godfather: Part II', year: 1994 },]

Then , in autocomplete when I search via year , I should get label options for title. Eg. If I enter year 1994 in search box , I should get two title options for selection -

The Shawshank Redemption
The Godfather: Part II

I tried changing option -

options={top100Films.map((option) => option.year)}

But through this I get year as a option which I want title as a option , having year entered in text box.

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

0

You can use MUI createFilterOptions

import { createFilterOptions } from '@mui/material/Autocomplete';

Declare filterOptions

const filterOptions = createFilterOptions({
  matchFrom: 'any',
  stringify: (option) => option.year.toString(),  //.toString because year is integer
});

Then in you Autocomplete tag add this:

filterOptions={filterOptions}

Codesandbox example.

The code is in javascript, you can change to typescript accordingly. For typescript follow this link

about 4 years ago · Juan Pablo Isaza Relatório

0

As I see you are using React js, so I will suggest you, to use React-select for better functionality

  1. Add Package using "npm i --save react-select".
  2. Import as a Component
  3. use <Select {data}/> in jsx format
  4. Add json data to {data}.

Reference documantion: React-select npm https://react-select.com/home

Everything is perfectly documented

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