I'm trying to set up a RadGrid with column filters that have values from the column itself, as demonstrated in the second RadGrid in this demo page: http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/basic-filtering/defaultcs.aspx
The columns for City, Country, and Contact Title have the functionality I need.
I have a RadGrid running in an ASP.NET Web Forms application, I've set AllowFilteringByColumn to true, and FilterType to "CheckList". I'm setting the datasource of the RadGrid programmatically at runtime to a list of objects. My goal is to set the column filter datasources programmatically at runtime as well, but none of the examples I've seen demonstrate a way to do this. The demo page linked above demonstrates this with a web service, and the column filters are created by referencing one of the web service methods. I don't want a database call for each one of my filterable columns, especially since I gather the necessary values when the page loads. As an example, two of my columns are User and Note Types. I use the following to extract a collection of distinct values:
var userNames = model.Results.Select(r => r.Username).Distinct().OrderBy(name => name);
var noteTypes = model.Results.Select(r => r.NoteType).Distinct().OrderBy(name => name);
I would very much like to simply assign these collections to the column filters in the RadGrid at runtime, rather than developing web services I don't need. Can this be done?