RadControls version
|
|
.NET version |
|
Visual Studio version |
|
programming language |
|
browser support |
all browsers supported by RadControls
|
PROJECT DESCRIPTION
This little snippet add a little icon near your Checkbox columns filter, so that you can clear filters, otherwise after the first time you filter the column clicking on the filter checkbox, you'll only be able to filter true/false values and the only way to remove filtering and get both values would be resorting to HeaderContext menu.
The script is very simple, it's executed in the grid ItemCreated event and scans for all your Checbox colums.
In the zip an appropriate icon for the Telerik default skin is also provided, remember to edit the script with the real path pointing to where you'll place the icon.
Very simple but very useful in my opinion.
Enjoy!
Protected
Sub
RadGrid1_ItemCreated(sender
As
Object
, e
As
GridItemEventArgs)
Handles
RadGrid1.ItemCreated
Dim
grid
As
RadGrid =
DirectCast
(sender, RadGrid)
' Tweak filter items
If
TypeOf
e.Item
Is
GridFilteringItem
Then
Dim
fltItem
As
GridFilteringItem =
DirectCast
(e.Item, GridFilteringItem)
For
Each
column
As
GridColumn
In
grid.Columns
' Add remove filters buttons for boolean columns
If
column.ColumnType =
"GridCheckBoxColumn"
And
column.Display
Then
AddClearFilterButton(column.UniqueName, fltItem, grid)
End
If
Next
End
If
End
Sub
Private
Sub
AddClearFilterButton(columnName
As
String
, fltItem
As
GridFilteringItem, grid
As
RadGrid)
'Dim grid As GridTableView = fltItem.OwnerTableView
Dim
clearFilterButton
As
New
ImageButton
clearFilterButton.ImageUrl =
"PATH_TO_YOUR_ICON_EDIT_THIS/grid-remove-filters.png"
AddHandler
clearFilterButton.Click,
Sub
(sender
As
Object
, e
As
ImageClickEventArgs)
grid.MasterTableView.GetColumn(columnName).CurrentFilterFunction = GridKnownFunction.NoFilter
grid.MasterTableView.GetColumn(columnName).CurrentFilterValue =
String
.Empty
grid.MasterTableView.FilterExpression =
String
.Empty
grid.MasterTableView.Rebind()
End
Sub
fltItem(columnName).Controls.Add(clearFilterButton)
End
Sub
It's in VB.NET but if you need C# version just head to Telerik Code converter. Beware of the AddHandler part for the click event if you convert to C# maybe this part will need a little bit of extra love from you ;)