Using custom filters

3 posts, 1 answers
  1. kabbas
    kabbas avatar
    11 posts
    Member since:
    May 2011

    Posted 26 Mar 2013 Link to this post

    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. Answer
    Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 28 Mar 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. kabbas
    kabbas avatar
    11 posts
    Member since:
    May 2011

    Posted 28 Mar 2013 Link to this post

    It worked, thank you very much.
Back to Top