We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Dropdownlist reactive form setValue not working


I'm having a problem assigning a value to a reactive form control dropdownlist. Value is not set.

Form definition:

  private defineForm() {
    this.form = this.fb.group({
      userName: new FormControl(this.authService.getUser().userName, [Validators.required, Validators.maxLength(50)]),
      startDate: new FormControl(new Date(), [Validators.required]),
      endDate: new FormControl('', [Validators.required]),
      reason: new FormControl('', [Validators.required]),
      approved: new FormControl(false, [Validators.required])

  get userName() { return this.form.get('userName'); }
  get startDate() { return this.form.get('startDate'); }
  get endDate() { return this.form.get('endDate'); }
  get reason() { return this.form.get('reason'); }
  get approved() { return this.form.get('approved'); }

This part works fine. Default value is assigned.

The next part is not working:


No value is assigned. If I look for this.userName, I see property 'value' with old value.

Any idea?

3 Replies

NP Narayanasamy Panneer Selvam Syncfusion Team October 24, 2019 05:01 PM UTC

Hi Jose, 
Greetings from Syncfusion Support. 
We have validated your requirement. Yes, we can update dropDownlist value through reactive form setValue method.  
Code example: 
<ejs-dropdownlist formControlName="skillname" name="skillname" [dataSource]='autoreactiveskillset' 
<button style="float:right" type="button" (click)="setDefaultValue()">Set Value</button> 
 public autoreactiveskillset: string[] = [ 
setDefaultValue() { 
  this.userForm.setValue({ name: 'John', skillname: 'Delphi', age: 20 }); 
We have prepared a sample to update dropdown list value using button click. Please get it from below link, 
Also, we would like to inform you that the DropDown List will accept only accept already present in referred data source. 
Kindly let us know if you need further assistance on this.

Narayanasamy P.

JL Jose Luis Garcia October 28, 2019 12:05 PM UTC

Hi Narayanasamy,

Thank you very much for your support.

I've tested agains your code and now is working fine.



SP Sureshkumar P Syncfusion Team October 29, 2019 09:00 AM UTC

Hi Jose, 
Most welcome. Please let us know if you require any further assistance. 
Sureshkumar P 

Live Chat Icon For mobile
Up arrow icon