How to not show the dropdown until typing occurs

Good morning,
     We are using a multiselect to choice items from a very long list (30K+ items) and we don't want the popup showing until the user starts typing in a 3+ letters, while still allowing a not in the list entry.

Regards

1 Reply 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team February 22, 2021 10:46 AM UTC

Hi David, 

Greetings from Syncfusion support. 

Yes, you can achieve the requested requirement by manual validation within the filter event handler. We have documented this information in the below link. Here the remote request does not fetch the filtered datasouce until the search key contains three characters, instead until 3 letters returned the entire datasource as like below. If you would like to return empty list, return the below if condition to meet your requirement. 

<div style='padding-top:75px;'> 
    <ejs-multiselect id="customers" placeholder="Select a customer" popupHeight="200px" allowFiltering="true" filtering="onfiltering" query="new ej.data.Query().from('Customers').select(['ContactName', 'CustomerID']).take(6)"> 
        <e-multiselect-fields value="CustomerID" text="ContactName"></e-multiselect-fields> 
        <e-data-manager url="https://services.odata.org/V4/Northwind/Northwind.svc/" adaptor="ODataV4Adaptor" crossDomain="true"></e-data-manager> 
    </ejs-multiselect> 
</div> 
<script> 
    function onfiltering(e) { 
        var CBObj = document.getElementById("customers").ej2_instances[0]; 
        // load overall data when search key empty. 
        if (e.text == '' && e.text.length < 3) { 
            e.updateData(CBObj.dataSource); 
        } 
        let query = new ej.data.Query().from('Customers').select(['ContactName', 'CustomerID']).take(6); 
        query = (e.text !== '' && e.text.length >= 3) ? query.where('ContactName', 'startswith', e.text, true) : query; 
        e.updateData(CBObj.dataSource, query); 
    } 
</script> 


Please get back us if you need further assistance. 

Regards, 
Ponmani M 


Marked as answer
Loader.
Up arrow icon