Inconsistent Dropdownlist Data

Hello,

I will try to outline the problem we are facing as well as I can. Basically we are calling multiple data retrievals to populate several Dropdownlists in a div using javascript. We are confident that the queries are returning the data properly (we console log the result and it is the same everytime) but once we set the data using this line of code: 

($("#TowStatusInput").ejDropDownList().data("ejDropDownList")).selectItemByText(e.result[0].Description);

Or something similar (we have multiple inputs), sometimes the dropdownlist is populated and other times the data isn't selected at all. We were wondering if it has something to do with a race condition, because it works if we introduce a setTimeout before the function call with 1000 milliseconds. Any help with this issue would be greatly appreciated, thank you.



3 Replies

KV Karthikeyan Viswanathan Syncfusion Team September 14, 2018 09:33 AM UTC

Hi Rameal, 

Thanks for contacting Syncfusion support. 

Based on your scenario, we suspect that the issue is raised due to the delay of data initialized into DropDownList. So, you can set the selectedText in dataBound event. It triggers after the data initialization.  

Please refer the below code example: 

<Code> 
$('#bikeList').ejDropDownList({ 
                dataSource: BikeList, 
                fields: { id: "empid", text: "text", value: "text" }, 
              dataBound: function() { 
              this.selectItemByText("Shine"); 
             
            }); 
</Code> 



Regards, 
Karthikeyan V. 



RN Rameal Nabeeh September 17, 2018 04:23 PM UTC

Thank you, that solution helped us out!


KV Karthikeyan Viswanathan Syncfusion Team September 18, 2018 05:47 AM UTC

Hi Rameal,  
 
Thanks for the update, 
 
We are glad to hear that your issue has been resolved. 
 
Regards, 
Karthikeyan V. 


Loader.
Up arrow icon