Explorar el Código

Added Expand/Collapse Button to Product Group Trees

frankvandenbos hace 1 mes
padre
commit
4c1283b59b

+ 30 - 1
prs.desktop/Panels/Products/Master List/ProductGroupTree.cs

@@ -11,17 +11,26 @@ using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Windows;
+using System.Windows.Controls;
 
 namespace PRSDesktop;
 
 public class ProductGroupTree : DynamicDataGrid<ProductGroup>
 {
     public Guid SelectedID { get; private set; }
+    
+    private Button _expandorcollapseAll;
+    
+    public ProductGroupTree() : base()
+    {
+        _expandorcollapseAll = AddButton("Collapse All", null, ExpandOrCollapseAll);
+    }
 
     protected override void DoReconfigure(DynamicGridOptions options)
     {
         base.DoReconfigure(options);
-
+        options.FilterRows = true;
+        options.HideDatabaseFilters = true;
         options.SelectColumns = false;
         options.ImportData = false;
         options.ExportData = false;
@@ -33,6 +42,26 @@ public class ProductGroupTree : DynamicDataGrid<ProductGroup>
         columns.Add<ProductGroup>(x => x.Description, 0, "Description", "", Alignment.MiddleLeft);
         return columns;
     }
+    
+    private bool ExpandOrCollapseAll(Button button, CoreRow[] rows)
+    {
+        if (_uiComponent == null)
+            return false;
+        
+        if (_uiComponent.Collapsed())
+        {
+            _uiComponent.ExpandAll();
+            UpdateButton(_expandorcollapseAll, null, "Collapse All", null);
+
+        }
+        else
+        {
+            _uiComponent.CollapseAll();
+            UpdateButton(_expandorcollapseAll, null, "Expand All", null);
+        }
+
+        return false;
+    }
 
     private DynamicGridTreeUIComponent<ProductGroup, Guid>? _uiComponent;
     private DynamicGridTreeUIComponent<ProductGroup, Guid> UIComponent

+ 1 - 1
prs.desktop/Panels/Products/Master List/ProductsPanel.xaml

@@ -13,7 +13,7 @@
         AllowableViews="Detail,Combined"
         View="Combined"
         Anchor="Master"
-        AnchorWidth="250">
+        AnchorWidth="350">
         <dynamicgrid:DynamicSplitPanel.Header>
             <Border BorderBrush="Gray" BorderThickness="0.75" Background="WhiteSmoke" Height="25">
                 <Label Content="Product Groups" HorizontalContentAlignment="Center"

+ 25 - 0
prs.desktop/Panels/Stock Forecast/StockForecastProductGroupTree.cs

@@ -7,21 +7,46 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Controls;
 using System.Windows.Media.Imaging;
 
 namespace PRSDesktop;
 
 public class StockForecastProductGroupTree : DynamicSelectorGrid<ProductGroup>, ISpecificGrid
 {
+    private Button _expandorcollapseAll;
+    
     public StockForecastProductGroupTree() : base(DynamicActionColumnPosition.End)
     {
         ColumnsTag = "StockForecastProductGroupSelector";
+        _expandorcollapseAll = AddButton("Collapse All", null, ExpandOrCollapseAll);
+    }
+
+    private bool ExpandOrCollapseAll(Button button, CoreRow[] rows)
+    {
+        if (_uiComponent == null)
+            return false;
+        
+        if (_uiComponent.Collapsed())
+        {
+            _uiComponent.ExpandAll();
+            UpdateButton(_expandorcollapseAll, null, "Collapse All", null);
+
+        }
+        else
+        {
+            _uiComponent.CollapseAll();
+            UpdateButton(_expandorcollapseAll, null, "Expand All", null);
+        }
+
+        return false;
     }
 
     protected override void DoReconfigure(DynamicGridOptions options)
     {
         base.DoReconfigure(options);
         options.FilterRows = true;
+        options.HideDatabaseFilters = true;
     }
 
     public override DynamicGridColumns GenerateColumns()