Q3 2011 is knocking on the door and along with all the cool stuff you will find inside, there is one feature that we would like to tell you about now. Do you remember Excel-Like functionality, which allows the end-user to effortlessly apply filter by selecting items from a popup list? Now we are including a bunch of new stuff to it.

 

Calendar filter popup
First of all is a new calendar popup. It will be shown by default for date columns, and it will allow for easily selecting a date from RadCalendar. For additional convenience, there are a couple of predefined options to choose from:

Excel-like Filtering Calendar 

But hey, that is not all. You can entirely customize all these predefined options. Here is the time to reveal another new feature: a new RadGridView event called FilterPopupRequired, which will allow you to access the popup, modify it or even use a custom popup.

Getting back to the date filter, there are three methods, which can be used to modify the items: AddCustomMenuItem, RemoveCustomMenuItem and ClearCustomMenuItems. An example of how to use them can be found below:

void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
{
    if (e.FilterPopup is RadDateFilterPopup)
    {
        RadDateFilterPopup popup = (RadDateFilterPopup)e.FilterPopup;
        popup.ClearCustomMenuItems();
  
        popup.AddCustomMenuItem("IsLessThanOrEqualTo - 15.08.1996", new DateFilterDescriptor("RequiredDate", FilterOperator.IsLessThanOrEqualTo, new DateTime(1996, 8, 15)));
  
        popup.AddCustomMenuItem("IsEqualTo 20.10.2011", new DateFilterDescriptor("RequiredDate", FilterOperator.IsEqualTo, new DateTime(2011, 10, 20)));
    }
}

And here is the result:

Excel-like Filtering Custom Items

Simple list filter popup
Another new feature is the simple list filter popup. Sometimes, there is a need to apply a simple filter with just one click. Here this new popup class comes in handy. It offers a list of values and one-click filtering functionality.
Excel-like Filtering List

Again, you can use FilterPopupRequired event to set it to a column of your choice:

void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
{
    if (e.Column.Name == "Country")
    {
        e.FilterPopup = new RadSimpleListFilterPopup(e.Column);
    }
}

 

Grouped Date Filter Popup
Probably, you have already noticed that there is some room for improvement in the way the filtering list represents a lot of date values. The new functionality addresses this task - it shows dates grouped by year and month, thus allowing for easily applying the filtering criteria:

Excel-like Filtering Grouped List

To employ this list, handle the FilterPopupRequired event and use the RadListFilterPopup’s constructor with two parameters:

void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
{
    if (e.Column.Name == "OrderDate")
    {
        e.FilterPopup = new RadListFilterPopup(e.Column, true);
    }
}

 

Custom Filter Popup
Last, but not least, if the enhancements introduced above are not enough to cover your requirements, then there is a way to create a custom filter popup object and use it along with your own filtering logic. The only requirement is that your filter popup should implement IGridFilterPopup. An instance of your custom popup can be assigned in the FilterPopupRequired event handler, as this is done with the built-in popups.

We hope that you will like the new enhancements. Happy coding!


About the Author

Nikolay Diyanov

is the Product Manager of Telerik's UI for iOS and UI for Xamarin divisions. He joined the company back in 2007 as a Support Officer and made his way up the ladder over the past few years. Delivering outstanding solutions that make developers lives easier is his passion and the biggest reward in his work. In his spare time, Nikolay enjoys travelling around the world, hiking, sun-bathing and kite-surfing.

@n_diyanov

Related Posts

Comments