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

Grid DropdownList AutoComplete

1 Answer 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Informed Sources
Top achievements
Rank 1
Informed Sources asked on 02 Dec 2014, 07:19 AM
Hi,

I have a grid in which I have bound the DropDownLists to data, but on one of the list, the data is a very large list of products. I don't want to load the entire list, I want to have the user type in 3 letters, then automatically load the dropdownlist and allow selection. As the user types in more, the DropDownList will have fewer products to choose between. I want to save the productID, but display Category -> Product Name. 

Is this possible?

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 04 Dec 2014, 07:50 AM
Hi Adam,

You can use the ComboBox widget with "ServerFiltering" option enabled - please check the example below:

Additionally you can restrict the response from the server to only return the top 10 records (for example) from the filter query:

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));
    }
 
    products = products.Take(5);
 
    return Json(products, JsonRequestBehavior.AllowGet);
}

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Informed Sources
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or