JavaScript/jQuery SelectBox - Customize Item Appearance

To customize the appearance of items in the SelectBox drop-down menu, configure itemTemplate (customizes all items) or items[].template (customizes individual items).

index.js
  • $(function() {
  • $("#selectBoxContainer").dxSelectBox({
  • itemTemplate: function(data) {
  • return $("<div>").append(
  • $("<img>").attr("src", data.imgSrc)
  • );
  • },
  • });
  • });

You can also customize the SelectBox input field. Configure fieldAddons.beforeTemplate and fieldAddons.afterTemplate to display custom markup to the left/right of the component input:

index.js
  • $(function() {
  • $("#selectBoxContainer").dxSelectBox({
  • fieldAddons: {
  • beforeTemplate: function(data) {
  • return $("<div>").append(
  • $("<img>").attr("src", data.imgSrc)
  • );
  • },
  • }
  • });
  • });
See Also