Combobox - is autocomplete possible as in Ajax control?

1 Answer 17 Views
ComboBox
Laurie
Top achievements
Rank 1
Laurie asked on 28 May 2021, 01:56 PM

In the Ajax control, you have the ability to filter a list and, if the term is not found, execute a command on the new term you typed in. This is in the Ajax demo at https://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/autocompleteclientside/defaultcs.aspx?_ga=2.149674102.1173080875.1622059656-840544784.1585530237 in the Autocomplete example at the top. I am not seeing this functionality replicated in the documentation for .NET Core. Is it possible to do something like this using a Tag Helper? If so, how would one go about it?

Thanks!

Laurie

p.s. For example, if I enter antoine@telerik.com (not found in the list), and click Submit, the message "You have selected the following email: antoine@teleri.com" will be displayed.

1 Answer, 1 is accepted

Sort by
1
Accepted
Stoyan
Telerik team
answered on 02 Jun 2021, 12:59 PM

Hi Laurie,

The Telerik UI for .NET Core's ComboBox Component has a similar functionality to the Ajax Demo you have linked.

I recommend to review its Demos and the Tag Helper Documentation. It showcases how to define a ComboBox via TagHelpers. You can subscribe to the ComboBox's Change event and then handle it in a script:

<kendo-combobox name="products" filter="FilterType.Contains "
                on-change="change"
                placeholder="Select product"
                datatextfield="ProductName"
                datavaluefield="ProductID"
                auto-bind="false"
                min-length="3" style="width: 100%;">
    <datasource type="DataSourceTagHelperType.Custom">
        <transport>
            <read url="@Url.Action("GetProducts", "Home")" />
        </transport>
    </datasource>
</kendo-combobox>

            function change(e) {
              if(e.sender.dataItem() == null){
                var value = this.text();
                alert('You selected a non-existing item: '+ value)
              } else {
                alert('You selected : '+ e.sender.dataItem().ProductName)
              }
            }

Review the behavior of the change event handler above in this Dojo.

In addition you can utilize Kendo Templates in the ComboBox's noDataTemplate configuration property to show a custom message, if the user input is not present in the Component's DataSource.

Please let me know, if you have further questions.

 

Regards,
Stoyan
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/.

Laurie
Top achievements
Rank 1
commented on 07 Jun 2021, 06:52 PM

Yes, this worked. Thanks!
Tags
ComboBox
Asked by
Laurie
Top achievements
Rank 1
Answers by
Stoyan
Telerik team
Share this question
or