We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to Clear or (Delete ) Selected items in Multiselect Dropdown By Clicking on external Button?

Hi,

How to Clear or (Delete ) Selected items in Multiselect Dropdown By Clicking on external Button?

Note: for more Explanation my view attached below.

(When I clicked on ADD Button Categories multiselect dropdown selected items is Cleared)


Thanks Very Much

3 Replies

BC Berly Christopher Syncfusion Team December 17, 2021 04:17 PM UTC

Hi Ahmed, 
  
Greetings from Syncfusion support. 
  
We can achieve the requested requirement with help of clearAll() method as mentioned in the below code example. 
  
<ejs-multiselect id="games" dataSource="@ViewBag.data" value="@ViewBag.value" width="250px" placeholder="Select a game" popupHeight="220px" mode="Box"></ejs-multiselect> 
 
<button id="btn">Click to Clear value</button> 
 
<script> 
    document.getElementById("btn").addEventListener("click",(e)=>{ 
        var multiObj = document.getElementById("games").ej2_instances[0 
        multiObj.clearAll(); 
    }) 
</script> 
 
  
  
Regards, 
Berly B.C 



AH Ahmed December 19, 2021 03:22 PM UTC

Hi Berly,

Thanks for response but ,

It have errors.

Note: I use asp.net core 3.1 .

for more details : code and errors attached

Multi Select :-


JavaScript Code:-

1.png


Error:

3.png

Thanks Very much



BC Berly Christopher Syncfusion Team December 20, 2021 04:33 PM UTC

Hi Ahmed, 
  
The clearAll() method is working fine at our end. So, we suggest you to call the clear() method or assign the value as null to achieve the requested requirement.  
  
   document.getElementById("btn").addEventListener("click",(e)=>{ 
        var multiObj = document.getElementById("games").ej2_instances[0]; 
        multiObj.value = null; 
    }) 
 
  
Still issue persists, please share the issue reproducing sample that will help us to check and proceed further at our end.  
  
Regards, 
Berly B.C 


Loader.
Up arrow icon