RadControls version
|
2012.3.1017.40 |
.NET version |
4.0+ |
Visual Studio version |
2012/2010 |
programming language |
VB.NET |
PROJECT DESCRIPTION
This is a bit of an enhancement for the excel filtering that is built into the RadGridView.
The tasks were:
a) When the filter popup is opened, the search text box should have the focus.
b) All the items in the filter list should be sorted.
c) When the filter is applied, the first row of the remaining visible rows should be selected and current.
SOLUTION
1. Create a custom implementation of the RadListFilterPopup
This is a 2-fold solution.
Firstly (b) you check if the column is a look-up type column. In the case that the data source is linked with a foreign key relationship, the bound value of the column would be an integer which is the identity value for the row that this record relates to in a child relationship. Due to this, the sorting in the filter list happens ascending on the numerical value and not on the text display value. This in turn causes the list to look "unsorted". So we force sort the display values that are under the ALL node in the tree view.
Secondly (a), we get access to the search text box in the popup and set the focus to the control so that when the popup opens or displays, you can just start typing to search for the value in the column.
Add these methods to the form where the grid is hosted.
2. Use the new popup implementation in the grid
3. Thirdly (c) ensure that after filter is applied, the first row in the remaining visible rows is selected and also the current row
As soon as the filter has been applied, check that there are remaining rows visible. If so, set the current row to the first row in the collection (grid.rows is the datasource rows, grid.masterview.rows is the visible row collection). We also take this opportunity to update and reload all the related grids on the screen by using the unique key from the master record to update related child record grids.
So that is it, simple yet very effective to give your users that polished feel.
Hope you find this informative and possibly open some doors for even more functionality.
Thank you
Theo Jacobs
P.S. Leave a comment if you think this is worth some much loved Telerik Points or if this helped you in any way. cheers