Can we disable a specific item in dropdownlist component using itemTemplate ?

I want to programmatically disable a specific item from a dropdownlist component.
I guess it can through the open method in dropdownlist, but that requires it to do that computation every time the list is opened. 


Is there any other way to do it, like thriugh the the itemTemplate ?


1 Reply

VJ Vinitha Jeyakumar Syncfusion Team August 11, 2022 01:11 PM UTC

Hi Aravind,


We have created a sample as per your requirement to disable the specific item in dropdown list using the item template. please check the sample and code below,

Code snippet:
itemTemplate(data) {
    var length = document.querySelectorAll('.e-list-item').length;
    for (var i = 0i < lengthi++) {
      if (
        data.IsDisabled == 'true' &&
        document
          .querySelectorAll('.e-list-item')
          [i].getAttribute('data-value') == '7'
      ) {
        document
          .querySelectorAll('.e-list-item')
          [i].classList.add('e-disabled');
        document.querySelectorAll('.e-list-item')[i].classList.add('e-overlay');
      }
    }




Regards,
Vinitha

Loader.
Up arrow icon