Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

296
Vistas
How to deactivate one or more items in a list-box using primeng or angular2?

I am trying to deactivate one or more items according to data. For example, I have a list of cities with disable/active field, for example, and I pushed the city names in a SelectItem[] array.

NewYork, active
Rome, disable
London, active
Istanbul, disable
Paris, active

enter image description here

 this.cities.push({label:'New York', value:'New York'});
 this.cities.push({label:'Rome', value:'Rome'}); // want to disable
 this.cities.push({label:'London', value:'London'});
 this.cities.push({label:'Istanbul', value:'Istanbul'}); // want to disable
 this.cities.push({label:'Paris', value:'Paris'});

I tried to render the list-box in using primeng example

<p-listbox [options]="cities" [(ngModel)]="selectedCity"  filter="filter">
  <ng-template let-city pTemplate="item" >
        <div class="ui-helper-clearfix">
            <span >{{city.value}}</span>
        </div>
  </ng-template>      
</p-listbox>

In primeng, list-box has one attribute called disabled. If I set it then it disabled the whole list-box. But I want to disable only the specific items. Here is the implemented Plunker https://plnkr.co/edit/7MHSzdmvIWNpdHsEy4F9?p=preview

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You could always create a mutator for selectedCity...

private _selectedCity: string;
private set selectedCity(city:string) {
    if(isactive){... do stuff ...}
}

However obviously this might not be great for user experience as the item would still be clickable.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda