Autocomplete

2 posts, 0 answers
  1. Sven
    Sven avatar
    4 posts
    Member since:
    Oct 2012

    Posted 11 Oct Link to this post

    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

     

  2. Neli
    Admin
    Neli avatar
    221 posts

    Posted 15 Oct Link to this post

    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.
Back to Top