Disable dropdownlist items with remote data

Hi,

Is there a way to disable certain items on creation of the dropdownlist using a field that is on the data that is returned from the remote data source?

Something like the following:

        $('#ProductId').ejDropDownList({
            width: '100%',
            enableFilterSearch: true,
            dataSource: ej.DataManager({
                url: "/Products/List",
                adaptor: new ej.UrlAdaptor()
            }),
            fields: { text: 'Name', value: 'Id', disabled: 'IsSelectable' },
            value: $('#ProductIdHidden').val(),
        });

1 Reply

MK Muthukrishnan Kandasamy Syncfusion Team May 18, 2020 07:37 AM UTC

Hi Malcolm, 
 
Thanks for contacting Syncfusion support. 
 
We have validated your requirements in the EJ DropDownList control. Yes, we can disable the specific items in the DropDownList control. To achieve this requirement, we have provided disableItemByIndices method, we can disable the items using this method. For remote data, we can use actionComplete event to disable the items. 
 
Please refer the below code block. 
 
$('#customerList').ejDropDownList({ 
              dataSource: dataManger, 
              enableFilterSearch: true, 
              fields: { text: "CustomerID" }, 
              query: query, 
              actionComplete: function (args) { 
                var DropDownListObj = $("#customerList").data("ejDropDownList"); 
                DropDownListObj.disableItemsByIndices(["1", "3"]); 
             } 
            }); 
 
 
We have prepared sample for your convenience, please refer to the below link for the sample. 
 
 
Please refer to the below link for API documentation of DropDownList. 
 
 
Please refer to the below link for ‘how-to’ documentation of DropDownList. 
 
 
Please let us know, if you need any further assistance. 
 
Regards, 
Muthukrishnan K 


Loader.
Up arrow icon