Custom Tokenizer in AutoCompleteBox

2 Answers 85 Views
AutoCompleteBox
Andrea
Top achievements
Rank 1
Andrea asked on 14 Jun 2021, 09:14 AM

Hi, just a question, it is feasible to use a custom tokenizer for the autocompletebox in order to compose the text blocks?

My tokenizer currently supports a vast variety of "quoted" parts, escape sequences and separators thus would be difficult to use just separators, because if separator is , then the quoted text "Hello, World", will be considered 2 blocks instead of 1.

Best Regards

Andrea

2 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 15 Jun 2021, 03:27 PM

Hello, Andrea,

The Delimiter property accepts only one char symbol to tokenized the items in the autocomplete box. So, it is expected if your delimiter is ',' the text "Hello, World" to be tokenized as two items. If you want to tokenize this text as one item, then you should another delimiter, for example ';'. 

this.radAutoCompleteBox1.Delimiter = ';';
this.radAutoCompleteBox1.Text = "Hello, World;";

Currently, RadAutoCompleteBox supports only one delimiter. However, we already have a similar feature request logged in our feedback portal. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I hope this information is useful. Let me know if you have other questions.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Andrea
Top achievements
Rank 1
commented on 17 Jun 2021, 09:00 AM

Thank for replying, changing the delimiter will not resolve the issue since quoted text may contain anything users want to type in there including separator characters (that's the purpose of quoted text).

The case use i would like to support is managing a list of mail address, unfortunately mail addresses are not easily separated by a separator nor by a simple regex: see example below these are 2 addresses, if you only split a string based on occurrence of comma you split the string in wrong places.

"John Doe, Boss of the company" <john.doe@company.com>, otheruser@othercompany.com

and this example is not the worst, since a mail address may have comments inside like

John Doe (boss, owner, deus ex machina) <john.doe@company.com>

So i either need something ready to handle mail addresses or use my parser which correcly parses mail addresses conforming to RFC specs.

Do not worry it is not something urgent, i was just checking out which options I have...

Thank you very much
Andrea
0
Nadya | Tech Support Engineer
Telerik team
answered on 18 Jun 2021, 11:38 AM

Hello, Andrea,

Currently, RadAutoCompleteBox supports only one delimiter. However, you can achieve behavior when entering different delimiters to convert them to the specified one. I prepared a sample example to demonstrate this:

public RadForm1()
{
    InitializeComponent();
    this.radAutoCompleteBox1.TextChanged += this.RadAutoCompleteBox1_TextChanged;

    this.radAutoCompleteBox1.Delimiter = ';';
    this.radAutoCompleteBox1.Text = "Hello, World;";

}
private void RadAutoCompleteBox1_TextChanged(object sender, EventArgs e)
{
    if (radAutoCompleteBox1.Text.EndsWith(";") || radAutoCompleteBox1.Text.EndsWith(",") || radAutoCompleteBox1.Text.EndsWith(" "))
    {
        radAutoCompleteBox1.Text = radAutoCompleteBox1.Text.Substring(0, radAutoCompleteBox1.Text.Length - 1) + radAutoCompleteBox1.Delimiter;
    }
}

Thus, you can enter different delimiters and still be able to tokenize the items. Note, that this is a sample demonstration and may not cover all possible cases. Feel free to use it if it is suitable for your requirements.

IF you have other questions do not hesitate to contact me. 

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
AutoCompleteBox
Asked by
Andrea
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or