The Clear Filters option in the FieldFilterControl cannot be selected when the DefaultOperator1 is set in the FilterOperatorsLoading event of RadGridView. The FieldFilterControl is the element shown under the column header when the FilteringMode property of RadGridView is set to FilterRow. Setting e.DefaulteOperator1 in the FilterOperatorsLoading properly selects the corresponding filter in the drop down, but after that you cannot select Clear Filters when clicking on this option.
To work this around, you can use the CellLoaded event instead of FilterOperatorsLoading. This will allow you to get the FieldFilterControlViewModel and set its SelectedOperatorViewModel property.
private void manualGridView_CellLoaded(object sender, CellEventArgs e)
{
if (e.Cell is GridViewHeaderCell && e.Cell.Column.UniqueName == "MyColumn")
{
Dispatcher.BeginInvoke(new Action(() =>
{
var fieldFilter = e.Cell.FindChildByType<FieldFilterControl>();
var viewModel = (FieldFilterControlViewModel)fieldFilter.DataContext;
viewModel.SelectedOperatorViewModel = viewModel.AvailableOperatorViewModels.FirstOrDefault(x => x.FilterOperator == FilterOperator.IsLessThan);
}));
}
}
The height of the column footer is not updated properly to autofit the footer's content. Actually, this works when the footer content becomes bigger than the current (or the default) value, but if you change the content with a smaller one, the bigger height remains. In other words, the footer height autofits when the content becomes bigger but it doesn't decrease when the content becomes smaller after that.
To work this around, you can subscribe to the CellLoaded event and use reflection to update one of the internal properties of the panel that draws the footer cells.private void gridView_CellLoaded(object sender, CellEventArgs e)
{
if (e.Cell is GridViewFooterCell)
{
var row = e.Cell.ParentRow;
Dispatcher.BeginInvoke(new Action(() =>
{
var aggregatesList = row.ChildrenOfType<AggregateResultsList>(); // the exact type of children that should be used to get the new height may vary based on your column Footer contents
if (aggregatesList.Count() > 0)
{
var height = aggregatesList.Max(x => x.ActualHeight);
var cellsPanel = e.Cell.ParentOfType<GridViewCellsPanel>();
PropertyInfo minRowHeightProp = cellsPanel.GetType().GetProperty("MinRowHeight", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
object minRowHeightPair = minRowHeightProp.GetValue(cellsPanel);
PropertyInfo heightProp = minRowHeightPair.GetType().GetProperty("Second");
heightProp.SetValue(minRowHeightPair, height);
}
}));
}
}
Currently, when you cancel the Filtering event the field filter (displayed when FilteringMode="FilterRow") will clear any entered text and the funnel icon won't change its color (like when the filter is active). Add an option in the Filtering event, similar to the Sorting event which allows you to manually set the sorting state of the column which will affect the UI (showing and changing the sort indicator icon).
In the case with the Filtering event, there should be an option if the funnel icon should be highlighted. In other words the setting should allow you to manually say if the filter is active or not. Also, the input text in the field filter should be preserved and possible an option to change this value may be added in the event arguments. This will allow you to implement custom filtering and keep the UI state of the field filter.
The column group headers are not displayed when the DisplayIndex property of the GridViewColumn objects is set before the control is loaded.
To work this around, you can set the DisplayIndex of the columns after the RadGridView is loaded.
Arrow keys (up and down) don't scroll the first row which is outside of the viewport. One way to reproduce this is to scroll down, then select the topmost visible row and press the Up arrow key in order to select the row above. This should scroll the view a bit up in order to see the previous row which is now selected.
Currently, this doesn't work when using a custom implementation of the GridViewCell class.
The issue is reproducible when GroupRenderMode is set to Flat.
To work this around, you can manually scroll to the row.
public MainWindow()
{
InitializeComponent();
this.gridView.AddHandler(RadGridView.KeyUpEvent, new KeyEventHandler(OnGridViewKeyUp), true);
}
private void OnGridViewKeyUp(object? sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.Up || e.Key == Key.Down)
{
Dispatcher.BeginInvoke(new Action(() =>
{
var currentCell = gridView.CurrentCell;
var row = currentCell.ParentRow;
// Since the VisualOffset proeprty is protected and you are already inheriting the GridViewRow class, you can just expose it through an extra property in the CustomGridViewRow, instead of using reflection like in this example.
var visualOffsetPropInfo = typeof(Visual).GetProperty("VisualOffset", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
var offset = (Vector)visualOffsetPropInfo.GetValue(row);
if (offset.Y < 0)
{
row.BringIntoView();
}
}));
}
}
InvalidCastException is thrown when the DropIndicatorThickness property of the GridViewHeaderCell is set. Or whenever the DropIndicatorBrush property is accessed. This happens when using the Windows 7 theme. Also, the EnableColumnVirtualization property should be set to False.
System.InvalidCastException: 'Unable to cast object of type 'System.Windows.Media.LinearGradientBrush' to type 'System.Windows.Media.SolidColorBrush'.'
To work this around, you can use an implicit style targeting the GridViewHeaderCell in order to set its DropIndicatorBrush to a SolidColorBrush value.
<telerik:RadGridView.Resources>
<Style TargetType="telerik:GridViewHeaderCell">
<Setter Property="DropIndicatorBrush" Value="White" />
<Setter Property="DropIndicatorThickness" Value="10" />
</Style>
</telerik:RadGridView.Resources>
Empty cells appear when the RadGridView contains many cells in the viewport and the view gets resized.
To work this around you can extract and modify the ControlTemplate of GridViewCell, in order to set the MinHeight property of the "PART_ContentPresenter" element to a number close to the RowHeight of the RadGridView control.