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

Using custom filters

2 Answers 92 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
kabbas
Top achievements
Rank 1
kabbas asked on 26 Mar 2013, 11:40 AM
Hello,

I'm wondering if I can use my custom developed filters with the multiselect, instead of being tied only to the ready-made ones (starts with, contains, equals)

I want to implement the custom filter server-side, i.e the multi-select makes an AJAX request with the query and the server makes the filtering then returns the results.

Thank you.

2 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 28 Mar 2013, 07:45 AM
Hello,

If you have enabled server filtering you can implement the filtering on your own:

Check the following ASP.NET demo

http://demos.kendoui.com/web/multiselect/serverfiltering.html

the action method look like this and it could be easily changed:

public JsonResult GetProducts(string text)
{
    var northwind = new NorthwindDataContext();
 
 
    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);
}


Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
kabbas
Top achievements
Rank 1
answered on 28 Mar 2013, 07:49 PM
It worked, thank you very much.
Tags
MultiSelect
Asked by
kabbas
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
kabbas
Top achievements
Rank 1
Share this question
or