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

189
Vistas
not able to get choice group target id to set values dynamically

This is my Choice Group element

 <ChoiceGroup defaultSelectedKey="No"
  options={[{ key: 'Yes', text: 'Yes' },{ key: 'No', text: 'No' }]}
  onChange={this._onChange}
  id={'ChoiceGroup1'}
  name={this.state.currentUser} />

and my onChange function

public _onChange=(ev, option: IChoiceGroupOption)=> {
console.log(ev,option); } 

but i am not able get target.id value. The target shows null but in case of Textfield i am able to get name and target of component

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can manually pass the selected item's id to the _onChange function.

Based on the props and the used case, i assume your ChoiceGroup component maps through the "options" prop and renders another component. If that's the case, you can tweak it a little bit to make it pass the clicked item up to the parent component (so you can decide what to do with it).

So in your ChoiceGroup component add

{options.map(option =>
<ChoiceGroupOption
  onClick={e => onItemSelected(option)}
/>}

 <ChoiceGroup defaultSelectedKey="No"
   options={[{ key: 'Yes', text: 'Yes' },{ key: 'No', text: 'No' }]}
   onItemSelected={item => this._onChange(e, item.id)}
   id={'ChoiceGroup1'}
   name={this.state.currentUser} />

Then in the event handler put this:

public _onChange = (ev, selectedId)=> {
    console.log('ID: ', selectedId);
}
about 4 years ago · Juan Pablo Isaza 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