How to grab the label of a multiselect clicked on Ngprime?

Asked

Viewed 10 times

0

I’m working on a project that uses Ngprime and Angular 10. I need to get the label of the checkbox that was clicked, only I don’t find any property that returns the label, only the complete list. I have this mock:

this.colunas = [
  {
    order: 0,
    label: 'ESTRATEGIA',
    value: 'ESTRATEGIA',
    field: 'estrategia.nome',
    header: 'ESTRATEGIA',
    filterList: this.estrategias,
    selectedList: this.estrategiasSelecionadas,
  },
  {
    order: 1,
    label: 'N. LOJAS',
    value: 'N. LOJAS',
    field: 'qtdLojas',
    header: 'N. LOJAS',
    filterList: this.lojas,
    selectedList: this.lojasSelecionadas,
  },
  {
    order: 2,
    label: 'QTD PECAS',
    value: 'QTD PECAS',
    field: 'quantidade',
    header: 'QTD PECAS',
    pipe:   this.decimalPipe,
    filterList: this.pecas,
    selectedList: this.pecasSelecionadas,
  },
  {
    order: 3,
    label: 'CICLO DE VIDA',
    value: 'CICLO DE VIDA',
    field: 'ciclo',
    header: 'CICLO DE VIDA',
    filterList: this.ciclosVida,
    selectedList: this.ciclosSelecionadas,
  },
  {
    order: 4,
    label: 'MES LOJA',
    value: 'MES LOJA',
    field: 'mes',
    header: 'MES LOJA',
    filterList: this.mesesLoja,
    selectedList: this.mesesSelecionadas,
  },
  {
    order: 5,
    label: 'DEMANDA',
    value: 'DEMANDA',
    field: 'demanda',
    header: 'DEMANDA',
    mapper: DemanadaSortmentoLabel,
    filterList: this.demandas,
    selectedList: this.demandasSelecionadas,
  },
  {
    order: 6,
    label: 'GM',
    value: 'GM',
    field: 'gm',
    header: 'GM',
    filterList: this.gms,
    selectedList: this.gmsSelecionadas,
  },
];

My HTML is like this:

<p-multiSelect
            #multiselect
            inputId="edicao_linha_multiselect_personalizar_colunas"
            optionLabel="label"
            [options]="colunas"
            [defaultLabel]="'Personalizar colunas'"
            [filter]="true"
            [style]="{ width: '250px', 'margin-right': '20px'}"
            [(ngModel)]="colunasSelecionadas"                
            (onChange)="onChangePersonalizarColunas($event.value)"
            [selectedItemsLabel]="'{0} itens selecionados'"
            [emptyFilterMessage]="'Nenhuma coluna encontrada'">
          </p-multiSelect>

It makes the filter Nma good, but I need to anyway get the label only from the checkbox that was clicked. Does anyone have any idea how I can do that?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.