Telerik: Grid-Dropdown Column Filter

Please see my other Telerik articles.

Providing a dropdown column filter

In my Telerik Grid Dropdown article (link), I demonstrated how to use a dropdown within a grid column, allowing users to choose between predefined choices.

However, the column’s filter method wasn’t very precise in that since the column only provided a predefined set of choices within the dropdown, the filter should’ve also worked on those choices. Instead, the filter worked based on what the user types – very lazy filtering.

In this article I will demonstrate how to change the field from using a editor template to the foreign key format, which includes built-in filtering matches choices provided to the user.

Instead of using a property, itself a type of another view model, I’ll explicitly state the ID and name properties in the grid’s model.

1.Telerik-Grid-DrodownColumnFilter

In the grid’s configuration, I’ll update the field to use the ID field and change how its populated.

2.Telerik-Grid-DrodownColumnFilter

Notice how I don’t need to specify an editor template because “ForeignKey” refers the razor engine to the default template in /Views/Shared/EditorTemplates.

3.Telerik-Grid-DrodownColumnFilter

I’ll also update the grid’s code setting the default value.

4.Telerik-Grid-DrodownColumnFilter

Finally, I’ll update the methods used to populate the dropdown and the grid when the page loads.

5.Telerik-Grid-DrodownColumnFilter

Now we have a grid field displaying a dropdown with choices also used by the column filter.

6.Telerik-Grid-DrodownColumnFilter7.Telerik-Grid-DrodownColumnFilter8.Telerik-Grid-DrodownColumnFilter