Flat array dropdown set value not working

I have an simple array bind to a dropdown. I am updating the array and getting the updated list back from server and I am trying to reassign the updated list to dataSource property which is working fine. However, I need to set the newly updated value as well in the dropdown after getting the results back .

I tried to reassign the value to ngModel property but it is not working. Have also tried .value property on dropdown but it is also not working as expected. 

Can you please assist?

3 Replies

SN Sevvandhi Nagulan Syncfusion Team April 9, 2020 12:56 PM UTC

Hello Samir, 

Greetings from Syncfusion support. 

The cause of the issue is you were updated the value property before the list has been generated for the dataSource. So we suggest to update value property in the actionComplete or dataBound event for as mentioned code example, 

[app.component.html] 
<ejs-dropdownlist id='games' #sample1  [(ngModel)]= 'dropVal' [dataSource]='sportsData' [fields]='localFields' [placeholder]='localWaterMark' [popupHeight]='height'  (actionComplete)='OnActionComplete($event)'></ejs-dropdownlist> 


[app.component.ts] 
       OnActionComplete(e){ 
      this.dropdownlistObj.value = "Game5"; 
    } 


Please find the sample below, 


Regards, 
Sevvandhi N 



SM Samir Modi April 19, 2020 10:31 AM UTC

Able to resolve this now. Thanks Sevvandhi



SN Sevvandhi Nagulan Syncfusion Team April 20, 2020 05:41 AM UTC

Hi Samir, 

Thanks for the update. 

Please let us know if you need any other further assistance on this. 

Regards, 
Sevvandhi N 


Loader.
Up arrow icon