I am using a combination of normal and custom filtering in the RadGridView control. When the user clears the text out of a filter box in the filtering row the grid still filters as if the box still had text in it.
In the attached image you can see that two rows show up in the grid initially.
After the filter value Contains "T" is entered the first row is correctly filtered.
When I clear that filter box the first row remains hidden. The only way to get the grid to show the row again is to set the filter type to "No Filter" and then back to "Contains".
Here is the sample code:
In the attached image you can see that two rows show up in the grid initially.
After the filter value Contains "T" is entered the first row is correctly filtered.
When I clear that filter box the first row remains hidden. The only way to get the grid to show the row again is to set the filter type to "No Filter" and then back to "Contains".
Here is the sample code:
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
radGridView1.CustomFiltering += radGridView1_CustomFiltering;
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
radGridView1.MasterTemplate.Columns.Clear();
GridViewTextBoxColumn v1Col =
new
GridViewTextBoxColumn(
"Value1"
);
v1Col.Name =
"Value1"
;
radGridView1.MasterTemplate.Columns.Add(v1Col);
GridViewTextBoxColumn v2Col =
new
GridViewTextBoxColumn(
"Value2"
);
v2Col.Name =
"Value2"
;
radGridView1.MasterTemplate.Columns.Add(v2Col);
radGridView1.MasterTemplate.EnableFiltering =
true
;
radGridView1.MasterTemplate.EnableCustomFiltering =
true
;
radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
BindingList<Thing> stuff =
new
BindingList<Thing>();
stuff.Add(
new
Thing(
"One"
,
"Two"
));
stuff.Add(
new
Thing(
"Filter"
,
"Two"
));
stuff.Add(
new
Thing(
"Three"
,
"Four"
));
radGridView1.DataSource = stuff;
}
private
void
radGridView1_CustomFiltering(
object
sender, Telerik.WinControls.UI.GridViewCustomFilteringEventArgs e)
{
if
((e.Row.DataBoundItem
as
Thing).Value1 ==
"Filter"
)
{
e.Visible =
false
;
}
e.Handled = !e.Visible;
}
}
public
class
Thing
{
public
string
Value1 {
get
;
set
; }
public
string
Value2 {
get
;
set
; }
public
Thing(
string
val1,
string
val2)
{
Value1 = val1;
Value2 = val2;
}
}