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

Clear button triggers a controller call with empty text

1 Answer 38 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
François
Top achievements
Rank 1
François asked on 18 Sep 2017, 01:39 PM

I set MinLength on Autocomplete.

However when I click on the "clear" icon of the autocmplete box there are a few unexpected behaviors

- there is a call to the controller with empty text

- the dropdown remains open saying "no data found"

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 21 Sep 2017, 12:02 PM
Hello Fran├žois,

In our demos when the input is cleared a request is sent to the server and it returns all the items. The No data found message is not displayed:
Here's the Action that is called:
public JsonResult GetProducts(string text)
{
    var northwind = new SampleEntities();
 
 
    var products = northwind.Products.Select(product => new ProductViewModel
    {
        ProductID = product.ProductID,
        ProductName = product.ProductName,
        UnitPrice = product.UnitPrice ?? 0,
        UnitsInStock = product.UnitsInStock ?? 0,
        UnitsOnOrder = product.UnitsOnOrder ?? 0,
        Discontinued = product.Discontinued
    });
 
    if (!string.IsNullOrEmpty(text))
    {
        products = products.Where(p => p.ProductName.Contains(text));
    }
 
    return Json(products, JsonRequestBehavior.AllowGet);
}

Could you share your AutoComplete declaration? This would give us a better idea of how it is configured. 

Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
AutoComplete
Asked by
François
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or