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

Prefill dropdown List with template

Good evening. I'm currently using the DropDownListComponent component with the ItemTemplate and ValueTemplate templates. however, I change the value of my component when loading the page in the componentDidmount lifecycle via a via a setState. the problem is that the value is not taken into account and when the popup opens the item list is invisible..

By adding the value property in the component and modifying its value I have this momentum. I left your example at 

https://ej2.syncfusion.com/react/demos/#/material/drop-down-list/template 



Thanks in advance and regards,



1 Reply

PO Prince Oliver Syncfusion Team May 21, 2019 07:18 AM UTC

Hello Toko, 
 
Thank you for contacting us. 
 
componentWillMount() is executed before the component rendering but whereas componentDidMount() is executed once the component has been rendered. When we change the value of the state, then we will be re-rendering in componenDidMount. It takes some time to reflect in the DOM tree. So, we suggest you use componentWillMount for updating the value property. Kindly refer to the following link for the sample 


Let us know if you need any further assistance on this. 

Regards, 
Prince 


Loader.
Live Chat Icon For mobile
Up arrow icon