This is a migrated thread and some comments may be shown as answers.

Autocomplete

1 Answer 216 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Sven
Top achievements
Rank 1
Sven asked on 11 Oct 2018, 09:20 AM

Hi,

I have following code:

    //Autocomplete Gemarkungssuche
    $("#al_gemarkung").kendoAutoComplete({
        minLength: 1,
        dataTextField: "bez",
        select: onSelectAlkisplace,
        enable: true,
        dataSource: new kendo.data.DataSource({
           transport: {
               read: "mod_alkis/gem_search.php",
               //parameter
               parameterMap: function(options, operation) {
                   return {
                       placename: options.filter.filters[0].value
                   }
               }
           },
           schema: {
               data: "data"
           },
           //Filter aufServer nicht Client
           serverFiltering: true
       })
    });   

if I enter a letter everything works fine, but if I go back to the beginning of my input with the backspace key or delete everything in the input field I get the following error in the console:
TypeError: options.filter.filters[0] is undefined
How can I prevent this?

Thanks Sven

 

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 15 Oct 2018, 07:23 AM
Hi Sven,

You could return the filter only if it has value. For example, if the filter is undefined, you could return empty string.
var placename = options.filter.filters.length > 0 ? options.filter.filters[0].value : ""
return {
placename: placename
}


Regards,
Neli
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
AutoComplete
Asked by
Sven
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or