In the 2014 Q2 release, we introduced two features that will greatly speed up your end-users’ working process with the data grid—a search functionality and a check-all checkbox in the column header.
Thanks to the friendly UI, the search functionality of the grid allows end-users to quickly navigate to cells that interest them. Searching through tens of thousands of cells takes time and using the main thread for time consuming tasks is never advisable, so this is why we implemented the search in a separate thread. This leaves the UI responsive and at the same time increases the speed of the search. In addition, there is a public API which gives access to the search mechanism, so you can utilize the functionality with or without showing the search row in the grid UI.
A valid alternative solution would be to filter the rows according to certain criteria. However, one filter criteria concerns just one column, while the search looks up all columns at once. Moreover, you may not want to hide and then show different rows upon changing the filter criteria, but instead always have all the rows visible.
Let’s now take a look at the options available to your end-users and how you can control their search behavior.
First of all, you can access the logical search row through the MasterView of RadGridView:
GridViewSearchRowInfo searchRow =
The SelectNextSearchResult and SelectPreviousSearchResult methods can be used for navigation through the search results.
Before we get to the event handler of the event let’s look at some more internal mechanics of the search mechanism. The search is executed on another thread so it would not hamper the responsiveness of the UI. One interesting thing we found during the development is that if you have many search results and you notify the UI thread of every “finding” immediately, you end up making so many invokes that the main thread is blocked handling them anyway. So we have a property called InitialSearchResultsTreshold. This is an integer number defining a number of search results that will be returned one by one. This way the search will very quickly display the initial results. The user would probably not care about the 100th and up result right after he inputs something, so after this number is reached search results are returned in groups. The size of the groups is controlled through the SearchResultsGroupSize property. The default values for these properties are 100 and 111 respectively. You may wonder why 111? It’s actually a simple trick to hide the grouping from the users. When you get lots of search results the label inside the search box updates with the new number very quickly, it becomes pretty much unreadable. If your group size is 100 the last two digits in this label will freeze until the last result group is return and only if its size is not 100. When the group size is 111 all digits “spin” all the time and it just looks better.
Now let’s get back to the event handler for the SearchProgressChanged event. You can have up to three cases here:
Coming from the above facts we can extract a couple of tips. Therefore, if you want all the results displayed one by one you should set the initial threshold to a big value. If you want the results all at once you should set it to 0 and the group size to a big value.
Now, if your end-users happen to lose something, they should not worry – the Search functionality have them covered.
We noticed a very high interest in a KB article of ours regarding “check all” functionality in RadGridView and with the Service pack of Q2 2014 we added this functionality (GridViewCheckBoxColumn) to RadGridView to save you the time of embedding it. Now, you just need to set a single property and your column will show a check box in the header cell. This functionality applies to a template level, so you can use it in hierarchy too:
GridViewCheckBoxColumn checkBoxColumn = (GridViewCheckBoxColumn)radGridView1.Columns[
Ivan Petrov is a Senior Software Developer working at the Telerik WinForms DevLabs. He joined the company back in 2010 after graduating from Telerik Academy. He holds a master's degree in Computer Systems and Technologies. In his spare time, Ivan is a motorsports fan, an avid gamer, a snowboarder and a mountain biker.”