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

Can I ignore specific characters in a search strng?

Thread ID:

Created:

Updated:

Platform:

Replies:

146241 Jul 28,2019 04:24 AM UTC Jul 29,2019 12:28 PM UTC Xamarin.Forms 2
loading
Tags: SfAutoComplete
Jesse Knott
Asked On July 28, 2019 04:24 AM UTC

Hello, I am working on a form where a user will select a caliber from a list of options. Calibers will begin with a "." but a lot of the time users forget that. So if they want to search for .357, they may type 357, like wise when selecting a specific size 9mm for instance there is no period, (but I would like to again be able to ignore when appropriate)

Is there any way to make the autocomplete control ignore characters, and still look for non literal but inferred strings? eg: .357 works because it's correct formatting, but 357 also works and assumes the leading "."

Thanks!


Jesse Knott
Replied On July 29, 2019 05:56 AM UTC

In hind sight (sorry I couldn't find a way to edit my original poat) Could a regex member field be applied? allowing the user to specify a regex over the autocomplete source items? I can imagine a few situations where that could be handy..

Thanks again!


Muneesh Kumar G [Syncfusion]
Replied On July 29, 2019 12:28 PM UTC

Hi Jesse, 
 
Greetings from Syncfusion.  
 
We have checked the reported scenario and achieved using SuggestionMode as Custom Search. Through Custom Search we can achieve our logic and set the text only by returning it to true. Please have the sample from the below link, 
 
 
Code Snippet: 
Xaml: 
 <autocomplete:SfAutoCompleteHeightRequest="40"DropDownTextSize="20"x:Name="autoComplete"AutoCompleteMode="Suggest"MaximumDropDownHeight="200"SuggestionMode="Custom"/> 
 
C#: 
public bool ContainingSpaceFilter(string search, object item)
        {
            string text = item.ToString().ToLower();
            if (item != null)
            {
                if (!search.Contains("."))
                {
                    search = search.Insert(0, ".");
                }

                if (text.StartsWith(search.ToLower()))
                {
                    return true;
                }
            }

            return false;
        } 
 
 
Please check with the sample and if the mentioned scenario differs from the sample please provide a video representation for the same which will be helpful for us to analyze further and provide an appropriate solution. 
   
Regards,  
Muneesh Kumar G.  
 


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