|
@@ -20,6 +20,7 @@ using System.Windows.Data;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
+using Syncfusion.UI.Xaml.TreeGrid.Filtering;
|
|
|
|
|
|
namespace InABox.DynamicGrid;
|
|
|
|
|
@@ -229,9 +230,14 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
|
|
|
cellStyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.White)));
|
|
|
_tree.RowStyle = cellStyle;
|
|
|
|
|
|
+ var filterstyle = new Style(typeof(TreeGridFilterControl));
|
|
|
+ filterstyle.Setters.Add(new Setter(TreeGridFilterControl.SortOptionVisibilityProperty, Visibility.Collapsed));
|
|
|
+ filterstyle.Setters.Add(new Setter(TreeGridFilterControl.ImmediateUpdateColumnFilterProperty, false));
|
|
|
+ _tree.FilterPopupStyle = filterstyle;
|
|
|
+
|
|
|
_tree.FilterChanged += _tree_FilterChanged;
|
|
|
_tree.FilterItemsPopulating += _tree_FilterItemsPopulating;
|
|
|
-
|
|
|
+ _tree.FilterLevel = FilterLevel.Extended;
|
|
|
_tree.SelectionForeground = DynamicGridUtils.SelectionForeground;
|
|
|
_tree.SelectionBackground = DynamicGridUtils.SelectionBackground;
|
|
|
|
|
@@ -379,9 +385,22 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
|
|
|
private void _tree_FilterItemsPopulating(object? sender, Syncfusion.UI.Xaml.TreeGrid.Filtering.TreeGridFilterItemsPopulatingEventArgs e)
|
|
|
{
|
|
|
var col = _tree.Columns.IndexOf(e.Column);
|
|
|
- if (GetColumn(col) is DynamicActionColumn column && column.Filters is not null)
|
|
|
- e.ItemsSource = column.Filters.Select(x => new FilterElement
|
|
|
- { DisplayText = x, ActualValue = x, IsSelected = column.SelectedFilters is null || column.SelectedFilters.Contains(x) });
|
|
|
+ if (GetColumn(col) is DynamicActionColumn dac && dac.Filters is not null)
|
|
|
+ {
|
|
|
+ e.ItemsSource = dac.Filters.Select(x => new FilterElement
|
|
|
+ {
|
|
|
+ DisplayText = x, ActualValue = x,
|
|
|
+ IsSelected = dac.SelectedFilters is null || dac.SelectedFilters.Contains(x)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else if (GetColumn(col) is DynamicGridColumn dgc)
|
|
|
+ {
|
|
|
+ var preds = e.Column.FilterPredicates.Select(x => x.FilterValue).ToArray();
|
|
|
+ var data = Parent.Data.Rows.Select(r => r.Get<String>(dgc.ColumnName)).OrderBy(x=>x);
|
|
|
+
|
|
|
+ e.ItemsSource = data.Select(x => new FilterElement()
|
|
|
+ { DisplayText = x ?? "(Blanks)", ActualValue = x, IsSelected = !preds.Any() || preds.Contains(x) });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void _tree_FilterChanged(object? sender, Syncfusion.UI.Xaml.TreeGrid.Filtering.TreeGridFilterChangedEventArgs e)
|
|
@@ -413,6 +432,8 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
|
|
|
{
|
|
|
FilterPredicates[e.Column.MappingName] = Serialization.Serialize(e.FilterPredicates, true);
|
|
|
}
|
|
|
+
|
|
|
+ Parent.UIFilterChanged(this);
|
|
|
|
|
|
UpdateRecordCount();
|
|
|
}
|
|
@@ -591,7 +612,7 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
|
|
|
{
|
|
|
filterstyle.Setters.Add(new Setter(Control.BackgroundProperty, DynamicGridUtils.FilterBackground));
|
|
|
column.ImmediateUpdateColumnFilter = true;
|
|
|
- column.ColumnFilter = ColumnFilter.Value;
|
|
|
+ column.ColumnFilter = ColumnFilter.DisplayText;
|
|
|
column.AllowBlankFilters = true;
|
|
|
column.AllowSorting = isactioncolumn
|
|
|
? false
|
|
@@ -646,7 +667,7 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
|
|
|
newcol.ColumnSizer = TreeColumnSizer.None;
|
|
|
newcol.HeaderText = column.HeaderText;
|
|
|
|
|
|
- ApplyFilterStyle(newcol, true, true);
|
|
|
+ ApplyFilterStyle(newcol, false, true);
|
|
|
|
|
|
newcol.ShowToolTip = column.ToolTip != null;
|
|
|
newcol.ShowHeaderToolTip = column.ToolTip != null;
|
|
@@ -710,9 +731,11 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
|
|
|
newcol.Width = column.Width;
|
|
|
newcol.ColumnSizer = TreeColumnSizer.None;
|
|
|
newcol.HeaderText = column.HeaderText;
|
|
|
- newcol.AllowFiltering = column.Filters != null && column.Filters.Any();
|
|
|
+ //newcol.AllowFiltering = column.Filters != null && column.Filters.Any();
|
|
|
newcol.AllowSorting = false;
|
|
|
newcol.ShowHeaderToolTip = column.ToolTip != null;
|
|
|
+
|
|
|
+ ApplyFilterStyle(newcol, false, true);
|
|
|
|
|
|
var headstyle = new Style(typeof(TreeGridHeaderCell));
|
|
|
headstyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
|
|
@@ -743,10 +766,12 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
|
|
|
newcol.Width = tmplCol.Width;
|
|
|
newcol.ColumnSizer = TreeColumnSizer.None;
|
|
|
newcol.HeaderText = column.HeaderText;
|
|
|
- newcol.AllowFiltering = false;
|
|
|
+ //newcol.AllowFiltering = false;
|
|
|
newcol.AllowSorting = false;
|
|
|
newcol.ShowToolTip = false;
|
|
|
newcol.ShowHeaderToolTip = false;
|
|
|
+
|
|
|
+ ApplyFilterStyle(newcol, false, true);
|
|
|
|
|
|
var headstyle = new Style(typeof(TreeGridHeaderCell));
|
|
|
headstyle.Setters.Add(new Setter(Control.BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
|
|
@@ -1000,7 +1025,7 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
|
|
|
|
|
|
public CoreRow[] GetVisibleRows()
|
|
|
{
|
|
|
- return _tree.View.Nodes.Select(x => MapRow((x.Item as CoreTreeNode)?.Row)).NotNull().ToArray();
|
|
|
+ return _tree.View?.Nodes.Select(x => MapRow((x.Item as CoreTreeNode)?.Row)).NotNull().ToArray() ?? new CoreRow[] { };
|
|
|
}
|
|
|
|
|
|
public void InvalidateRow(CoreRow row)
|