Country and Flags in Combobox

Hi, I have a list of countries displayed in the combo box and associated flags with it. Is there a way to display the flags?


3 Replies

KP Kokila Poovendran Syncfusion Team May 17, 2024 07:18 AM UTC

Hi Naveen Davuluri


Greetings from Syncfusion Support!


Thank you for reaching out to us with your query about displaying country flags in a ComboBox. We have prepared a sample based on your requirement.Please find the attached sample code below:



<ejs-combobox id="employees" dataSource="@data" placeholder="Select a country" popupHeight="270px"

              headerTemplate="@Html.Raw("<div class=\"header\"> <span>Flag</span> <span class=\"info\" style='padding-left:5px'>Country</span></div>")"

              itemTemplate="@Html.Raw("<div style='padding:10px'><img class=\"empImage\" src=\"${Flag}\" alt=\"employee\"/><div class=\"ename\"> ${Name} </div></div>")">

    <e-combobox-fields text="Name"></e-combobox-fields>

</ejs-combobox>



In the above code snippet, we have customized the ComboBox to display countries with their respective flags using the "itemTemplate" property.

For more details, please refer to the following links:  


Demohttps://ej2.syncfusion.com/aspnetcore/combobox/template#/material3

Documentationhttps://ej2.syncfusion.com/aspnetcore/documentation/combo-box/templates#item-template





If you have any further questions or need additional assistance, please feel free to reach out.




ND Naveen Davuluri May 23, 2024 06:13 PM UTC

Hi, by any chance, could you point me to a demo where this so that i can look at the source/data source?



KP Kokila Poovendran Syncfusion Team May 27, 2024 05:21 AM UTC

Hi Naveen Davuluri,


Sorry for the inconvenience caused. Please find the sample in the attachment below. If you encounter any issues, please let us know.



Attachment: ASPCoreSamples_3995bb97.zip

Loader.
Up arrow icon