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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Manipulate custom values at entry time

Thread ID:

Created:

Updated:

Platform:

Replies:

144238 Apr 26,2019 12:25 AM UTC Apr 26,2019 07:14 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: MultiSelect Dropdown
Jake Adams
Asked On April 26, 2019 12:25 AM UTC

Hi guys, I have a multiselect which allows custom entries. My use case is the user can enter an email address or select one from a predefined list. What I'd like to achieve is when the user enters a custom value, it is automatically checked against a regex to determine validity and removed if it is not. First off, I can't seem to get the customValueSelection event to fire. I can get select to respond but then I'm struggling with that removal step. 

In the code below I'm just trying to remove anything the user enters 

<ejs-multiselect id="txtTo" allowCustomValue="true" select="tochange" placeholder="To" floatLabelType="Auto" delimiterChar=";">
                            <e-multiselect-fields text="EMAIL" value="EMAIL"></e-multiselect-fields>
                        </ejs-multiselect>

<script>
        function tochange(args) {
            console.log(args);
            $("#txtTo")[0].ej2_instances[0].removeValue(args.itemData.EMAIL);
        }
<script>

Can someone please advise what I'm doing wrong?

Ashokkumar Balasubramanian [Syncfusion]
Replied On April 26, 2019 07:14 AM UTC

Hi Jake Adams, 
 
Greetings from Syncfusion support. 
 
We were able to remove the custom value on selection in MultiSelect component. In our MultiSelect component customValueSelection event will fired only on select custom values and returned corresponding event cancel parameter. If you need to remove the invalid typed text mean, set true value for cancel (args.cancel = true) parameter in customValueSelection event. 
 
Also, you need to restrict the selected value for already loaded items means, we suggest use the select event and set true value for cancel parameter. If you do this in select event, corresponding value is not updated to input element. Please find the code snippet for your reference. 
 
<div id='multiselect' class='col-lg-6' style='padding-top:15px'> 
<ejs-multiselect id="txtTo" allowCustomValue="true" select="tochange" customValueSelection="onCustomSelection" placeholder="To" delimiterChar=";" floatLabelType="Auto"> 
<e-multiselect-fields text="EMAIL" value="EMAIL"></e-multiselect-fields> 
</ejs-multiselect> 
</div> 
 
<script> 
function onCustomSelection(args) { 
args.cancel = true; // restring the custom value selection. 
} 
function tochange(e) { 
args.cancel = true; // restrict the select value. 
} 
</script> 
 
 
Please check the above provided code blocks and do the logic for your need in your application and update if you need any further assistance. 
 
Regards, 
Ashokkumar B. 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon