In some themes the clear filter ellipse button is visible, nevertheless, no filter is applied.
It is observable in ControlDefault, Office2010Silver, Office2007Black, Office2007Silver, and Windows7.
As a workaround, you can consider using one of our latest themes: Fluent for example.
Private Sub Filter_CategoryCreating(sender As Object, e As FilterViewCategoryCreatingEventArgs)
AddHandler DirectCast(e.Category, FilterViewBooleanCategoryElement).ItemCreated, AddressOf BoolCategoryItemCreated
Use the following code and press the arrow of the spin editor for the Price category in RadFilterView:
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Price", typeof(decimal));
for (int i = 0; i < 10; i++)
{
dt.Rows.Add(i,"Item"+i, null);
}
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radFilterView1.AssociatedControl = this.radGridView1;
The following error occurs:
Use the following code snippet
public RadForm1()
{
InitializeComponent();
DataTable dt = new DataTable();
for (int i = 0; i < 20; i++)
{
dt.Columns.Add("col" + i, typeof(string));
}
for (int i = 0; i < 10; i++)
{
DataRow r = dt.NewRow();
foreach (DataColumn col in dt.Columns)
{
r[col.ColumnName] = Guid.NewGuid().ToString();
}
dt.Rows.Add(r);
}
this.radFilterView1.DataSource = dt;
}
You will notice that after running the project, the vertical scrollbar is missing:
Workaround:
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
MethodInfo mi = typeof(RadFilterViewElement).GetMethod("UpdateScrollbars", BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(this.radFilterView1.FilterViewElement, new object[] { this.radFilterView1.FilterViewElement.ElementsPanel.Size });
}
An extended workaround that covers the case for updating the scrollbar at run time is demonstrated here:
private void radFilterView1_CategoryCreated(object sender, Telerik.WinControls.UI.FilterView.FilterViewCategoryCreatedEventArgs e)
{
e.Category.ExpandedChanged += Category_ExpandedChanged;
e.Category.Expanded = false;
}
private void Category_ExpandedChanged(object? sender, EventArgs e)
{
// You need pass the control to Windows main loop to perform the pending telerik events after property Expanded change in order to resize internally
// the StackLayoutPanel Containers before calling UpdateScrollBars
Application.DoEvents();
// Now your code
MethodInfo mi = typeof(RadFilterViewElement).GetMethod("UpdateScrollbars", BindingFlags.Instance | BindingFlags.NonPublic);
mi.Invoke(this.radFilterView1.FilterViewElement, new object[] { this.radFilterView1.FilterViewElement.ElementsPanel.Size });
// Hide the horizontal scrolll bar
radFilterView1.FilterViewElement.HorizontalScrollBar.Visibility =ElementVisibility.Collapsed;
}
Use the following code snippet which result is illustrated in the gif file:
public RadForm1()
{
InitializeComponent();
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Column1", typeof(decimal));
dt.Columns.Add("Column2", typeof(string));
dt.Columns.Add("Column3", typeof(string));
for (int i = 0; i < 10; i++)
{
//No delay
//dt.Rows.Add(i, 100, "LongstringAAAAAA" + i, "VeryVeryLongstringAAAAAAAABBBBBBBBVeryVeryLongstringAAAAAAAABBBBBBBBE" + i);
//Long delay
dt.Rows.Add(i, 10000, "LongstringAAAAAA" + i, "VeryVeryLongstringAAAAAAAABBBBBBBBVeryVeryLongstringAAAAAAAABBBBBBBBE" + i);
}
this.radFilterView1.DataSource = dt;
}
Workaround:
private void radFilterView1_CategoryCreating(object sender, Telerik.WinControls.UI.FilterView.FilterViewCategoryCreatingEventArgs e)
{
FilterViewNumericCategoryElement numericCategory = e.Category as FilterViewNumericCategoryElement;
if (numericCategory!=null)
{
numericCategory.DisplayMode = FilterViewNumericCategoryMode.SpinEditors;
}
}
Add a RadFilterView and a RadGridView. Associate the two controls and add programmatically FilterDescriptors to the RadFilterView control. The UI doesn't show any filtering applied.
Me.RadFilterView1.FilterViewElement.LoadCategoriesAsync = False
Me.RadGridView1.DataSource = Me.ProductsBindingSource
Me.RadGridView1.EnableFiltering = True
Me.RadGridView1.ShowFilteringRow = False
AddHandler Me.RadFilterView1.FilterChanged, AddressOf Me.RadFilterView1_FilterChanged
AddHandler Me.RadFilterView1.FilterViewElement.CategoryCreating, AddressOf Me.FilterViewElement_CategoryCreating
AddHandler Me.RadFilterView1.FilterViewElement.CategoryCreated, AddressOf Me.FilterViewElement_CategoryCreated
Me.RadFilterView1.AssociatedControl = Me.RadGridView1
Dim filter As New FilterDescriptor With {
.PropertyName = "ProductID",
.Operator = FilterOperator.IsLessThanOrEqualTo,
.Value = 5,
.IsFilterEditor = True
}
Dim filter2 As New FilterDescriptor With {
.PropertyName = "CategoryID",
.Operator = FilterOperator.IsLessThanOrEqualTo,
.Value = 4,
.IsFilterEditor = True
}
Me.RadFilterView1.FilterDescriptors.AddRange(filter, filter2)
To reproduce:
this.radGridView1.EnableFiltering = true;
this.radGridView1.BestFitColumns();
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Column 1", Type.GetType("System.Decimal")));
dt.Columns.Add(new DataColumn("Column 2", Type.GetType("System.Decimal")));
dt.Columns.Add(new DataColumn("Column 3", Type.GetType("System.String")));
for (int i = 0; i < 20; i++)
{
dt.Rows.Add(0, i, "Text " + i);
}
this.radGridView1.DataSource = dt;
this.radFilterView1.AssociatedControl = this.radGridView1;
Run the project and filter the first column ("Column 1") by dragging radFilterViews radTrackBar.
You will get the following exception: "System.ArgumentOutOfRangeException: 'Value of '1' is not valid for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'."