Possible to add the number of same element into the list ?

Hello, 

Is it possible to add next to the dropdown list's element, the number of duplicate element

If in the dropdown list we have two '30' is it possible to add a text like 'x2' next to the element

See the attachment

Thanks

Attachment: OpenedWithImage_2d202d5a.7z

1 Reply

PO Prince Oliver Syncfusion Team October 18, 2018 12:42 PM UTC

Hi Julien, 

Thank you for contacting Syncfusion support. 

We have prepared sample based your requirement. We have achieved your requirement using the itemCreated event to find the duplicate values, added ‘Xtimes’ in item template based on the number of duplicates and removed the duplicates. Kindly refer to the following code snippet. 
 
itemCreated: function (e) { 
  var div = document.createElement("div"); 
  div.className = "tempCount"; 
  var noOfDupItem = 1; 
  for (var i = 0; i < dupvalue.length; i++) { 
      if (dupvalue[i].toString() === e.item.getAttribute('data-value')){ 
          noOfDupItem++; 
          div.textContent = "X" + noOfDupItem; 
          if (isAdded.indexOf(e.item.getAttribute('data-value')) == -1){ 
              e.item.querySelector('#temp').appendChild(div); 
              isAdded.push(e.item.getAttribute('data-value')); 
          } else if (!e.item.querySelector('.tempCount')) { 
              e.item.style.display = 'none' 
          } 
      } 
  } 
} 
 
We have attached the sample for your reference, please find the sample at the following location: http://www.syncfusion.com/downloads/support/forum/140401/ze/Duplicate_items_sample-795424608.zip  
 
Please let us know if you require any further assistance on this. 
 
Regards, 
Prince 



Loader.
Up arrow icon