Refresh Datasource

Hi Syncfusion Team,

i have a dropdownlist and init like this:

selectUser = new ej.dropdowns.DropDownList({
popupHeight: "300px", 
dataSource: arrUsers, 
fields: {value: 'tPersonal1', text: 'tPersonal2'},
placeholder: "Operario",
allowFiltering: true
});
selectUser.appendTo("#selectUser");

At init time the arrUsers is a empty array, then i get from a ajax call the data.

How can i refresh the datasource?

Thank you in advance, and if you need more details just let me know.

Regards Miguel

5 Replies

KV Karthikeyan Viswanathan Syncfusion Team August 14, 2018 10:23 AM UTC

Hi Miguel, 

Thanks for contacting Syncfusion support. 

Based on your scenario, you can assign the data to control in Ajax success by using DropDownList instance. 

Please refer the below code example: 

<code> 

onSuccess: function(args) {  

selectUser. dataSource = args.result;  

</code> 


Regards, 
Karthikeyan V. 



MV Miguel Varela Rodriguez August 14, 2018 11:19 AM UTC

thank you :)

now it looks like it got the data correctly, but i have a strange behavior.

List is filled with items, but is like empty no text etc.

see screenshot attached.



Attachment: screenshot_37eff0d7.zip


KV Karthikeyan Viswanathan Syncfusion Team August 14, 2018 11:44 AM UTC

Hi Miguel,  
 
Based on your shared code and screenshot, we suspect that the issue is raised due to typo issue in field mapping. 
 
 Please refer the below code example: 
 
<code> 
 
selectUser = new ej.dropdowns.DropDownList({ 
                        popupHeight: "300px",  
                        dataSource: arrUsers,  
                        fields: {value: 'tpersonal1', text: 'tpersonal2'}, 
                        placeholder: "Operario", 
                        allowFiltering: true 
            }); 
 
 
</code> 
 
Regards,  
Karthikeyan V. 



MV Miguel Varela Rodriguez August 14, 2018 01:48 PM UTC

you are totally right!

sorry for waisting your time, dumb error :/




KV Karthikeyan Viswanathan Syncfusion Team August 15, 2018 03:28 AM UTC

Hi Miguel, 
 
We are glad to hear that your issue has been resolved.     
 
Regards,  
Karthikeyan V.  


Loader.
Up arrow icon