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

Multi-Select Filtering with distinct values

2 Answers 498 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jonah
Top achievements
Rank 1
Jonah asked on 22 Feb 2016, 04:12 PM

Hi,

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 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 23 Feb 2016, 09:59 AM
Hi Johan,

Please examine the code of this demo:
http://demos.telerik.com/aspnet-mvc/grid/filter-multi-checkboxes

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" }
        }).ToList();
    return View();
}

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


Regards,
Vasil
Telerik
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
0
Jonah
Top achievements
Rank 1
answered on 24 Feb 2016, 07:49 AM

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

Kind Regards,

Jonah Mevert

Tags
Chart
Asked by
Jonah
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Jonah
Top achievements
Rank 1
Share this question
or