Multi-Select Filtering with distinct values

3 posts, 0 answers
  1. Jonah
    Jonah avatar
    2 posts
    Member since:
    Feb 2016

    Posted 22 Feb Link to this post


    I'm currently looking into multi-select filtering for grids; I'm working with a very extensive grid that contains more than 100,000 meteorologic measured data from only about 30 distinct cities. I want the user of the grid to be able to filter the grid by one, multiple or all cities. In my controller, I do have a method that returns an array of the distinct city names, but I've yet to find a method to implement this.

    This is the current code for the relevant column:

    columns.Bound(c => c.MeteringStation).Title("Messstation").Width(200).Filterable(ftb => ftb.Multi(true).BindTo());

    I figured I'd use .BindTo() for this, because .DataSource() doesn't seem to work. However, I don't know how to bind remote data to BindTo().

    Thanks in advance


  2. Vasil
    Vasil avatar
    1540 posts

    Posted 23 Feb Link to this post

    Hi Johan,

    Please examine the code of this demo:

    In the second grid you will find 2 methods of adding custom data to the list. First is by using the DataSource
    columns.Bound(e => e.FirstName).Width(220).Filterable(ftb => ftb.Multi(true)
        .DataSource(ds => ds.Read(r => r.Action("Unique", "Grid").Data("{ field: 'FirstName' }")))

    And the second using BindTo:
    columns.Bound(e => e.City).Width(220).Filterable(ftb => ftb.Multi(true).CheckAll(false).BindTo(new[]{
            new { City = "Seatle" },
            new { City = "Tacoma" },
            new { City = "Kirkland" },
            new { City = "Redmond" },
            new { City = "London" }

    The third option is to use the
    public ActionResult Filter_Multi_Checkboxes()
        ViewBag.Items = (new[]{
                    new { City = "Seatle" },
                    new { City = "Tacoma" },
                    new { City = "Kirkland" },
                    new { City = "Redmond" },
                    new { City = "London" }
        return View();

    columns.Bound(e => e.City).Width(220).Filterable(ftb => ftb.Multi(true).CheckAll(false).BindTo(ViewBag.Items));

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET AJAX banner
  4. Jonah
    Jonah avatar
    2 posts
    Member since:
    Feb 2016

    Posted 24 Feb in reply to Vasil Link to this post

    Thanks a lot for your answer, the third option worked for me! 

    Kind Regards,

    Jonah Mevert

Back to Top