Kenric Nugteren před 4 měsíci
rodič
revize
1396a6fd88

+ 1 - 0
InABox.Core/Objects/Editors/Utils/DataLookupEditor.cs

@@ -72,6 +72,7 @@ namespace InABox.Core
             foreach (var key in OtherColumns.Keys)
                 result.OtherColumns[key] = OtherColumns[key];
             result.LookupWidth = LookupWidth;
+            result.ParentType = ParentType;
             return result;
         }
     }

+ 1 - 4
inabox.wpf/DigitalForms/Designer/DynamicFormControlGrid.cs

@@ -14,12 +14,9 @@ namespace InABox.DynamicGrid
             Items = new List<T>();
         }
 
-        protected override void Init()
-        {
-        }
-
         protected override void DoReconfigure(DynamicGridOptions options)
         {
+            base.DoReconfigure(options);
             options.RecordCount = true;
         }
 

+ 2 - 2
inabox.wpf/DigitalForms/DynamicVariableGrid.cs

@@ -324,11 +324,11 @@ namespace InABox.DynamicGrid
                 CoreTable? values;
                 if (o.ColumnName == "Property")
                 {
-                    values = def.Values(typeof(DigitalForm), colname, new[] { form });
+                    values = def.Values(colname, new[] { form });
                 }
                 else
                 {
-                    values = def.Values(typeof(DFLayoutFieldProperties), colname, new[] { item });
+                    values = def.Values(colname, new[] { item });
                 }
 
                 o.LoadLookups(values);

+ 4 - 0
inabox.wpf/DynamicGrid/DynamicGridColumn/DynamicColumnGrid.cs

@@ -17,6 +17,8 @@ public class DynamicColumnGrid : DynamicGrid<DynamicGridColumn>
 
     protected override void Init()
     {
+        base.Init();
+
         var column = MasterColumns.FirstOrDefault(x => string.Equals(x.ColumnName, nameof(DynamicGridColumn.ColumnName)));
         if(column is not null && column.Editor is DynamicColumnNameEditor edit)
         {
@@ -26,6 +28,8 @@ public class DynamicColumnGrid : DynamicGrid<DynamicGridColumn>
 
     protected override void DoReconfigure(DynamicGridOptions options)
     {
+        base.DoReconfigure(options);
+
         options.RecordCount = true;
         options.MultiSelect = true;
         options.AddRows = true;

+ 102 - 110
inabox.wpf/DynamicGrid/Editors/JsonEditor/JsonEditorControl.cs

@@ -8,138 +8,130 @@ using System.Windows.Controls;
 using System.Windows.Media;
 using InABox.Core;
 
-namespace InABox.DynamicGrid
+namespace InABox.DynamicGrid;
+
+internal class DynamicJsonGrid<T> : DynamicGrid<T> where T : BaseObject, new()
 {
-    internal class DynamicJsonGrid<T> : DynamicGrid<T> where T : BaseObject, new()
+    private int rowindex = -1;
+
+    public override void DeleteItems(params CoreRow[] rows)
     {
-        private int rowindex = -1;
+        var indexes = rows.Select(x => x.Index).OrderBy(x => x).ToArray();
+        foreach (var index in indexes)
+            Data.Rows.RemoveAt(index);
+    }
 
-        protected override void Init()
-        {
-        }
-        protected override void DoReconfigure(DynamicGridOptions options)
-        {
-        }
+    public override T LoadItem(CoreRow row)
+    {
+        rowindex = row.Index;
+        return row.ToObject<T>();
+    }
 
-        public override void DeleteItems(params CoreRow[] rows)
-        {
-            var indexes = rows.Select(x => x.Index).OrderBy(x => x).ToArray();
-            foreach (var index in indexes)
-                Data.Rows.RemoveAt(index);
-        }
+    protected override void Reload(
+        Filters<T> criteria, Columns<T> columns, ref SortOrder<T>? sort, 
+        CancellationToken token, Action<CoreTable?, Exception?> action)
+    {
+    }
 
-        public override T LoadItem(CoreRow row)
+    public override void SaveItem(T item)
+    {
+        CoreRow row;
+        if (rowindex == -1)
         {
-            rowindex = row.Index;
-            return row.ToObject<T>();
+            row = Data.NewRow();
+            Data.Rows.Add(row);
         }
-
-        protected override void Reload(
-            Filters<T> criteria, Columns<T> columns, ref SortOrder<T>? sort, 
-            CancellationToken token, Action<CoreTable?, Exception?> action)
+        else
         {
+            row = Data.Rows[rowindex];
         }
 
-        public override void SaveItem(T item)
-        {
-            CoreRow row;
-            if (rowindex == -1)
-            {
-                row = Data.NewRow();
-                Data.Rows.Add(row);
-            }
-            else
-            {
-                row = Data.Rows[rowindex];
-            }
-
-            Data.FillRow(row, item);
-        }
+        Data.FillRow(row, item);
     }
+}
 
-    internal class JsonEditorControl : DynamicEditorControl<string, JsonEditor>
+internal class JsonEditorControl : DynamicEditorControl<string, JsonEditor>
+{
+    
+                    
+    static JsonEditorControl()
     {
-        
-                        
-        static JsonEditorControl()
-        {
-            //DynamicEditorControlFactory.Register<JsonEditorControl, JsonEditor>();
-        }
-        
-        private Button _button;
+        //DynamicEditorControlFactory.Register<JsonEditorControl, JsonEditor>();
+    }
+    
+    private Button _button;
 
-        private string _value = "";
+    private string _value = "";
 
-        public JsonEditorControl()
-        {
-            Width = 150;
-        }
+    public JsonEditorControl()
+    {
+        Width = 150;
+    }
 
-        public override int DesiredHeight()
-        {
-            return 25;
-        }
+    public override int DesiredHeight()
+    {
+        return 25;
+    }
 
-        public override int DesiredWidth()
-        {
-            return 150;
-        }
+    public override int DesiredWidth()
+    {
+        return 150;
+    }
 
-        public override void SetColor(Color color)
-        {
-            _button.Background = new SolidColorBrush(color);
-        }
+    public override void SetColor(Color color)
+    {
+        _button.Background = new SolidColorBrush(color);
+    }
 
-        public override void SetFocus()
-        {
-            // Not Sure what to do here?
-        }
-        public override void Configure()
-        {
-        }
+    public override void SetFocus()
+    {
+        // Not Sure what to do here?
+    }
+    public override void Configure()
+    {
+    }
 
-        protected override FrameworkElement CreateEditor()
-        {
-            _button = new Button();
-            _button.Content = "Edit";
-            _button.Click += _button_Click;
-            return _button;
-        }
+    protected override FrameworkElement CreateEditor()
+    {
+        _button = new Button();
+        _button.Content = "Edit";
+        _button.Click += _button_Click;
+        return _button;
+    }
 
-        private void _button_Click(object sender, RoutedEventArgs e)
-        {
-            var type = (EditorDefinition as JsonEditor).Type;
-            var listtype = typeof(List<>).MakeGenericType(type);
-            var list = Activator.CreateInstance(listtype) as IList;
-            if (!string.IsNullOrWhiteSpace(_value))
-                Serialization.DeserializeInto(_value, list);
-
-            var array = new object[list.Count];
-            list.CopyTo(array, 0);
-
-            var data = new CoreTable();
-            data.LoadColumns(type);
-            data.LoadRows(array);
-
-            /*var gridtype = typeof(DynamicJsonGrid<>).MakeGenericType(type);
-            var grid = Activator.CreateInstance(gridtype) as IDynamicGrid;
-            grid.Data = data;
-            if (grid.DirectEdit(data))
-            {
-                var saved = data.Rows.Select(x => x.ToObject(type)).ToArray();
-                _value = Serialization.Serialize(saved, true);
-                CheckChanged();
-            }*/
-        }
+    private void _button_Click(object sender, RoutedEventArgs e)
+    {
+        var type = (EditorDefinition as JsonEditor).Type;
+        var listtype = typeof(List<>).MakeGenericType(type);
+        var list = Activator.CreateInstance(listtype) as IList;
+        if (!string.IsNullOrWhiteSpace(_value))
+            Serialization.DeserializeInto(_value, list);
+
+        var array = new object[list.Count];
+        list.CopyTo(array, 0);
+
+        var data = new CoreTable();
+        data.LoadColumns(type);
+        data.LoadRows(array);
+
+        /*var gridtype = typeof(DynamicJsonGrid<>).MakeGenericType(type);
+        var grid = Activator.CreateInstance(gridtype) as IDynamicGrid;
+        grid.Data = data;
+        if (grid.DirectEdit(data))
+        {
+            var saved = data.Rows.Select(x => x.ToObject(type)).ToArray();
+            _value = Serialization.Serialize(saved, true);
+            CheckChanged();
+        }*/
+    }
 
-        protected override string RetrieveValue()
-        {
-            return _value;
-        }
+    protected override string RetrieveValue()
+    {
+        return _value;
+    }
 
-        protected override void UpdateValue(string value)
-        {
-            _value = "";
-        }
+    protected override void UpdateValue(string value)
+    {
+        _value = "";
     }
 }

+ 3 - 0
inabox.wpf/DynamicGrid/Grids/DynamicDataGrid.cs

@@ -75,6 +75,7 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
 
     protected override void Init()
     {
+        base.Init();
         FilterComponent = new(this,
             new GlobalConfiguration<CoreFilterDefinitions>(GetTag()),
             new UserConfiguration<CoreFilterDefinitions>(GetTag()));
@@ -86,6 +87,8 @@ public class DynamicDataGrid<TEntity> : DynamicGrid<TEntity>, IDynamicDataGrid w
     }
     protected override void DoReconfigure(DynamicGridOptions options)
     {
+        base.DoReconfigure(options);
+
         if (Security.CanEdit<TEntity>())
         {
             options.AddRows = true;

+ 2 - 4
inabox.wpf/DynamicGrid/Grids/DynamicEnclosedListGrid.cs

@@ -44,12 +44,10 @@ public class DynamicEnclosedListGrid<TOne, TMany> : DynamicGrid<TMany>, IDynamic
         ColumnsComponent = new(this, null);
     }
 
-    protected override void Init()
-    {
-    }
-
     protected override void DoReconfigure(DynamicGridOptions options)
     {
+        base.DoReconfigure(options);
+
         options.RecordCount = true;
         options.SelectColumns = true;
     }

+ 79 - 89
inabox.wpf/DynamicGrid/Grids/DynamicExportMappingGrid.cs

@@ -6,111 +6,101 @@ using System.Windows.Media.Imaging;
 using InABox.Core;
 using InABox.WPF;
 
-namespace InABox.DynamicGrid
-{
-    public class DynamicExportMappingGrid : DynamicGrid<ImportMapping>
-    {
-        private readonly BitmapImage selected = Wpf.Resources.Bullet_Tick.AsBitmapImage();
+namespace InABox.DynamicGrid;
 
-        public DynamicExportMappingGrid()
-        {
-            HideBlank = false;
+public class DynamicExportMappingGrid : DynamicGrid<ImportMapping>
+{
+    private readonly BitmapImage selected = Wpf.Resources.Bullet_Tick.AsBitmapImage();
 
-            Items = new List<ImportMapping>();
-            Selected = new List<ImportMapping>();
+    public DynamicExportMappingGrid()
+    {
+        HideBlank = false;
 
-            ActionColumns.Add(new DynamicImageColumn(SelectedImage, SelectedAction));
-            HiddenColumns.Add(x => x.Key);
-        }
+        Items = new List<ImportMapping>();
+        Selected = new List<ImportMapping>();
 
-        protected override void Init()
-        {
-        }
+        ActionColumns.Add(new DynamicImageColumn(SelectedImage, SelectedAction));
+        HiddenColumns.Add(x => x.Key);
+    }
 
-        protected override void DoReconfigure(DynamicGridOptions options)
-        {
-            //options.RecordCount = true;
-        }
+    public List<ImportMapping> Items { get; }
 
-        public List<ImportMapping> Items { get; }
+    public List<ImportMapping> Selected { get; }
 
-        public List<ImportMapping> Selected { get; }
+    public bool HideBlank { get; set; }
 
-        public bool HideBlank { get; set; }
+    public override void DeleteItems(params CoreRow[] rows)
+    {
+        var deletes = new List<ImportMapping>();
+        foreach (var row in rows)
+            deletes.Add(Items[row.Index]);
+        Items.RemoveAll(x => deletes.Contains(x));
+        Selected.RemoveAll(x => deletes.Contains(x));
+    }
 
-        public override void DeleteItems(params CoreRow[] rows)
-        {
-            var deletes = new List<ImportMapping>();
-            foreach (var row in rows)
-                deletes.Add(Items[row.Index]);
-            Items.RemoveAll(x => deletes.Contains(x));
-            Selected.RemoveAll(x => deletes.Contains(x));
-        }
-
-        public override ImportMapping LoadItem(CoreRow row)
-        {
-            return Items[row.Index];
-        }
+    public override ImportMapping LoadItem(CoreRow row)
+    {
+        return Items[row.Index];
+    }
 
-        protected override void Reload(
-            Filters<ImportMapping> criteria, Columns<ImportMapping> columns, ref SortOrder<ImportMapping>? sort, 
-            CancellationToken token, Action<CoreTable?, Exception?> action)
-        {
-            var result = new CoreTable();
-            result.LoadColumns(typeof(ImportMapping));
-            if (HideBlank)
-                result.LoadRows(Items.Where(x => Selected.Contains(x)));
-            else
-                result.LoadRows(Items);
-            action.Invoke(result, null);
-        }
+    protected override void Reload(
+        Filters<ImportMapping> criteria, Columns<ImportMapping> columns, ref SortOrder<ImportMapping>? sort, 
+        CancellationToken token, Action<CoreTable?, Exception?> action)
+    {
+        var result = new CoreTable();
+        result.LoadColumns(typeof(ImportMapping));
+        if (HideBlank)
+            result.LoadRows(Items.Where(x => Selected.Contains(x)));
+        else
+            result.LoadRows(Items);
+        action.Invoke(result, null);
+    }
 
-        public override void SaveItem(ImportMapping item)
-        {
-            if (!Items.Contains(item))
-                Items.Add(item);
-        }
+    public override void SaveItem(ImportMapping item)
+    {
+        if (!Items.Contains(item))
+            Items.Add(item);
+    }
 
-        protected override DynamicGridColumns LoadColumns()
+    protected override DynamicGridColumns LoadColumns()
+    {
+        return new DynamicGridColumns
         {
-            return new DynamicGridColumns
-            {
-                new() { ColumnName = "Property", Width = 0 }
-            };
-        }
+            new() { ColumnName = "Property", Width = 0 }
+        };
+    }
 
-        public void ClearAll()
-        {
-            Selected.Clear();
-            Selected.AddRange(Items.Where(x => x.Key));
-            Refresh(false, true);
-        }
+    public void ClearAll()
+    {
+        Selected.Clear();
+        Selected.AddRange(Items.Where(x => x.Key));
+        Refresh(false, true);
+    }
 
-        public void SelectAll()
-        {
-            Selected.Clear();
-            Selected.AddRange(Items);
-            Refresh(false, true);
-        }
+    public void SelectAll()
+    {
+        Selected.Clear();
+        Selected.AddRange(Items);
+        Refresh(false, true);
+    }
 
-        private BitmapImage SelectedImage(CoreRow? arg)
-        {
-            if (arg == null)
-                return selected;
-            var property = arg.Get<ImportMapping, string>(x => x.Property);
-            return Selected.Any(x => x.Property.Equals(property)) ? selected : null;
-        }
+    private BitmapImage SelectedImage(CoreRow? arg)
+    {
+        if (arg == null)
+            return selected;
+        var property = arg.Get<ImportMapping, string>(x => x.Property);
+        return Selected.Any(x => x.Property.Equals(property)) ? selected : null;
+    }
 
-        private bool SelectedAction(CoreRow? arg)
-        {
-            var property = arg?.Get<ImportMapping, string>(x => x.Property);
-            var items = arg == null ? Items.ToArray() : new[] {  Items.Where(x => x.Property.Equals(property)).First() };
-            foreach (var item in items)
-                if (Selected.Contains(item) && !item.Key)
-                    Selected.Remove(item);
-                else
-                    Selected.Add(item);
-            return true;
-        }
+    private bool SelectedAction(CoreRow? arg)
+    {
+        var property = arg?.Get<ImportMapping, string>(x => x.Property);
+        var items = arg == null ? Items.ToArray() : new[] {  Items.Where(x => x.Property.Equals(property)).First() };
+        foreach (var item in items)
+            if (Selected.Contains(item) && !item.Key)
+                Selected.Remove(item);
+            else
+                Selected.Add(item);
+        return true;
     }
 }

+ 26 - 2
inabox.wpf/DynamicGrid/Grids/DynamicGrid.cs

@@ -178,6 +178,8 @@ public abstract class BaseDynamicGrid : ContentControl, IDynamicGridUIComponentP
 
         VisibleColumns = new DynamicGridColumns();
 
+        PreInit();
+
         UIComponent = CreateUIComponent();
         
         Loading = new Label();
@@ -330,6 +332,10 @@ public abstract class BaseDynamicGrid : ContentControl, IDynamicGridUIComponentP
         Reconfigure();
     }
 
+    protected virtual void PreInit()
+    {
+    }
+
     #region IDynamicGridUIComponentParent
 
     protected virtual IDynamicGridUIComponent CreateUIComponent()
@@ -900,6 +906,18 @@ public abstract class BaseDynamicGrid : ContentControl, IDynamicGridUIComponentP
             Columns = columns;
             ColumnGroupings = columnGroupings;
         }
+
+        public DynamicGridColumn Add<T>(
+            Expression<Func<T, object?>> member,
+            int? width = null,
+            string? caption = null,
+            string? format = null,
+            Alignment? alignment = null)
+        {
+            var col = DynamicGridColumns.CreateColumn(member, width: width, caption: caption, format: format, alignment: alignment);
+            Columns.Add(col);
+            return col;
+        }
     }
     
     public delegate void ColumnsLoadedEvent(BaseDynamicGrid sender, ColumnsLoadedEventArgs args);
@@ -1629,10 +1647,13 @@ public abstract class DynamicGrid<T> : BaseDynamicGrid, IDynamicGridUIComponentP
     protected override bool CanDuplicate => typeof(T).IsAssignableTo(typeof(IDuplicatable));
 
     public DynamicGrid() : base()
+    {
+    }
+
+    protected sealed override void PreInit()
     {
         MasterColumns = new DynamicGridColumns();
         MasterColumns.ExtractColumns(typeof(T));
-        ConfigureColumns(MasterColumns);
 
         HiddenColumns = new HiddenColumnsList();
 
@@ -1641,6 +1662,9 @@ public abstract class DynamicGrid<T> : BaseDynamicGrid, IDynamicGridUIComponentP
             HiddenColumns.Add(x => (x as ISequenceable)!.Sequence);
         }
     }
+    protected override void Init()
+    {
+    }
 
     #region IDynamicGridUIComponentParent
 
@@ -1700,7 +1724,7 @@ public abstract class DynamicGrid<T> : BaseDynamicGrid, IDynamicGridUIComponentP
 
     public void AddHiddenColumn(string column) => HiddenColumns.Add(column);
 
-    public HiddenColumnsList HiddenColumns { get; }
+    public HiddenColumnsList HiddenColumns { get; private set; }
 
     private static bool IsSequenced => typeof(T).GetInterfaces().Any(x => x.Equals(typeof(ISequenceable)));
 

+ 2 - 4
inabox.wpf/DynamicGrid/Grids/DynamicGridFilterGrid.cs

@@ -34,12 +34,10 @@ namespace InABox.DynamicGrid
             OnCustomiseEditor += DynamicGridFilterGrid_OnCustomiseEditor;
         }
 
-        protected override void Init()
-        {
-        }
-
         protected override void DoReconfigure(DynamicGridOptions options)
         {
+            base.DoReconfigure(options);
+
             options.RecordCount = true;
             options.AddRows = true;
             options.EditRows = true;

+ 163 - 162
inabox.wpf/DynamicGrid/Grids/DynamicImportMappingGrid.cs

@@ -7,224 +7,225 @@ using System.Windows.Media.Imaging;
 using InABox.Core;
 using InABox.WPF;
 
-namespace InABox.DynamicGrid
+namespace InABox.DynamicGrid;
+
+public class DynamicImportMappingGrid : DynamicGrid<ImportMapping>
 {
-    public class DynamicImportMappingGrid : DynamicGrid<ImportMapping>
-    {
-        private readonly BitmapImage create = Wpf.Resources.tick.AsBitmapImage();
+    private readonly BitmapImage create = Wpf.Resources.tick.AsBitmapImage();
 
-        private readonly BitmapImage key = Wpf.Resources.key.AsBitmapImage();
+    private readonly BitmapImage key = Wpf.Resources.key.AsBitmapImage();
 
-        private readonly BitmapImage restrict = Wpf.Resources.warning.AsBitmapImage();
+    private readonly BitmapImage restrict = Wpf.Resources.warning.AsBitmapImage();
 
-        public DynamicImportMappingGrid()
-        {
-            UniqueCode = "";
+    public DynamicImportMappingGrid()
+    {
+        UniqueCode = "";
 
-            HideBlank = false;
+        HideBlank = false;
 
-            Items = new List<ImportMapping>();
-        }
+        Items = new List<ImportMapping>();
+    }
 
-        protected override void Init()
-        {
-            ActionColumns.Add(new DynamicImageColumn(KeyImage, KeyAction) { Position = DynamicActionColumnPosition.Start, ToolTip = KeyToolTip });
-            HiddenColumns.Add(x => x.Key);
+    protected override void Init()
+    {
+        base.Init();
+        ActionColumns.Add(new DynamicImageColumn(KeyImage, KeyAction) { Position = DynamicActionColumnPosition.Start, ToolTip = KeyToolTip });
+        HiddenColumns.Add(x => x.Key);
 
-            ActionColumns.Add(new DynamicImageColumn(LookupImage, LookupAction) { ToolTip = LookupToolTip });
-            HiddenColumns.Add(x => x.Lookup);
-        }
+        ActionColumns.Add(new DynamicImageColumn(LookupImage, LookupAction) { ToolTip = LookupToolTip });
+        HiddenColumns.Add(x => x.Lookup);
+    }
 
-        protected override void DoReconfigure(DynamicGridOptions options)
-        {
-            options.RecordCount = true;
-            options.DirectEdit = true;
-        }
+    protected override void DoReconfigure(DynamicGridOptions options)
+    {
+        base.DoReconfigure(options);
+        options.RecordCount = true;
+        options.DirectEdit = true;
+    }
 
-        public List<ImportMapping> Items { get; }
+    public List<ImportMapping> Items { get; }
 
-        public string UniqueCode { get; set; }
+    public string UniqueCode { get; set; }
 
-        public bool HideBlank { get; set; }
+    public bool HideBlank { get; set; }
 
-        public override void DeleteItems(params CoreRow[] rows)
-        {
-            var deletes = new List<ImportMapping>();
-            foreach (var row in rows)
-                deletes.Add(Items[row.Index]);
-            Items.RemoveAll(x => deletes.Contains(x));
-        }
+    public override void DeleteItems(params CoreRow[] rows)
+    {
+        var deletes = new List<ImportMapping>();
+        foreach (var row in rows)
+            deletes.Add(Items[row.Index]);
+        Items.RemoveAll(x => deletes.Contains(x));
+    }
 
-        public override ImportMapping LoadItem(CoreRow row)
-        {
-            return Items[row.Index];
-        }
+    public override ImportMapping LoadItem(CoreRow row)
+    {
+        return Items[row.Index];
+    }
 
-        protected override void Reload(
-            Filters<ImportMapping> criteria, Columns<ImportMapping> columns, ref SortOrder<ImportMapping>? sort, 
-            CancellationToken token, Action<CoreTable?, Exception?> action)
+    protected override void Reload(
+        Filters<ImportMapping> criteria, Columns<ImportMapping> columns, ref SortOrder<ImportMapping>? sort, 
+        CancellationToken token, Action<CoreTable?, Exception?> action)
+    {
+        //Lookups.Clear();
+        var result = new CoreTable();
+        result.LoadColumns(typeof(ImportMapping));
+        if (HideBlank)
+            result.LoadRows(Items.Where(x => !string.IsNullOrWhiteSpace(x.Field) || !string.IsNullOrWhiteSpace(x.Constant)));
+        else
+            result.LoadRows(Items);
+        foreach(var item in Items)
         {
-            //Lookups.Clear();
-            var result = new CoreTable();
-            result.LoadColumns(typeof(ImportMapping));
-            if (HideBlank)
-                result.LoadRows(Items.Where(x => !string.IsNullOrWhiteSpace(x.Field) || !string.IsNullOrWhiteSpace(x.Constant)));
-            else
-                result.LoadRows(Items);
-            foreach(var item in Items)
+            if(!item.Field.IsNullOrWhiteSpace() && !ImportFieldGenerator.Fields.Contains(item.Field))
             {
-                if(!item.Field.IsNullOrWhiteSpace() && !ImportFieldGenerator.Fields.Contains(item.Field))
-                {
-                    item.Field = "";
-                }
+                item.Field = "";
             }
-            action.Invoke(result, null);
         }
+        action.Invoke(result, null);
+    }
 
-        public override void SaveItem(ImportMapping item)
+    public override void SaveItem(ImportMapping item)
+    {
+        if (!Items.Contains(item))
+            Items.Add(item);
+    }
+
+    private FrameworkElement? KeyToolTip(DynamicActionColumn column, CoreRow? row)
+    {
+        var result = "";
+        if (row == null)
+            result = "This column is used to indicate which fields form the unique key imported records";
+        else
         {
-            if (!Items.Contains(item))
-                Items.Add(item);
+            var key = row.Get<ImportMapping, bool>(x => x.Key);
+            result = key
+                ? "This field forms part (or all) of the unique key for imported records"
+                : "";
         }
+        return column.TextToolTip(result);
+    }
 
-        private FrameworkElement? KeyToolTip(DynamicActionColumn column, CoreRow? row)
+    private FrameworkElement? LookupToolTip(DynamicActionColumn column, CoreRow? row)
+    {
+        var result = "";
+        if (row == null)
+            result = "This column determines whether or not lookup values are automatically created as required, or cause the import to fail.";
+        else
         {
-            var result = "";
-            if (row == null)
-                result = "This column is used to indicate which fields form the unique key imported records";
-            else
-            {
-                var key = row.Get<ImportMapping, bool>(x => x.Key);
-                result = key
-                    ? "This field forms part (or all) of the unique key for imported records"
-                    : "";
-            }
-            return column.TextToolTip(result);
+            var lookup = row.Get<ImportMapping, ImportLookupType>(x => x.Lookup);
+            result = lookup == ImportLookupType.None
+                ? ""
+                : lookup == ImportLookupType.Create
+                    ? "Create Lookup Values as required"
+                    : "Restrict Importing for invalid / non-existent Lookup Values";
         }
+        return column.TextToolTip(result);
+    }
 
-        private FrameworkElement? LookupToolTip(DynamicActionColumn column, CoreRow? row)
+    public void Reset()
+    {
+        foreach (var item in Items)
         {
-            var result = "";
-            if (row == null)
-                result = "This column determines whether or not lookup values are automatically created as required, or cause the import to fail.";
-            else
-            {
-                var lookup = row.Get<ImportMapping, ImportLookupType>(x => x.Lookup);
-                result = lookup == ImportLookupType.None
-                    ? ""
-                    : lookup == ImportLookupType.Create
-                        ? "Create Lookup Values as required"
-                        : "Restrict Importing for invalid / non-existent Lookup Values";
-            }
-            return column.TextToolTip(result);
+            item.Key = false;
+            item.Field = "";
+            item.Constant = "";
+            item.Lookup = item.Lookup == ImportLookupType.Create ? ImportLookupType.Restrict : item.Lookup;
         }
 
-        public void Reset()
+        Refresh(false, true);
+    }
+
+    public void MatchFields()
+    {
+        foreach (var item in Items)
         {
-            foreach (var item in Items)
+            var field = ImportFieldGenerator.Fields.FirstOrDefault(x => String.Equals(item.Property.ToUpper(), x.ToUpper()));
+            if (!String.IsNullOrWhiteSpace(field))
+            {
+                item.Field = field;
+                if (item.Property.Equals(UniqueCode))
+                    item.Key = true;
+            }
+            else
             {
                 item.Key = false;
                 item.Field = "";
                 item.Constant = "";
                 item.Lookup = item.Lookup == ImportLookupType.Create ? ImportLookupType.Restrict : item.Lookup;
             }
-
-            Refresh(false, true);
         }
 
-        public void MatchFields()
-        {
-            foreach (var item in Items)
-            {
-                var field = ImportFieldGenerator.Fields.FirstOrDefault(x => String.Equals(item.Property.ToUpper(), x.ToUpper()));
-                if (!String.IsNullOrWhiteSpace(field))
-                {
-                    item.Field = field;
-                    if (item.Property.Equals(UniqueCode))
-                        item.Key = true;
-                }
-                else
-                {
-                    item.Key = false;
-                    item.Field = "";
-                    item.Constant = "";
-                    item.Lookup = item.Lookup == ImportLookupType.Create ? ImportLookupType.Restrict : item.Lookup;
-                }
-            }
-
-            Refresh(false, true);
-        }
+        Refresh(false, true);
+    }
 
-        private BitmapImage? KeyImage(CoreRow? arg)
-        {
-            if (arg == null)
-                return key;
-            return arg.Get<ImportMapping, bool>(x => x.Key) ? key : null;
-        }
+    private BitmapImage? KeyImage(CoreRow? arg)
+    {
+        if (arg == null)
+            return key;
+        return arg.Get<ImportMapping, bool>(x => x.Key) ? key : null;
+    }
 
-        private bool KeyAction(CoreRow? arg)
+    private bool KeyAction(CoreRow? arg)
+    {
+        if (arg == null)
+            return false;
+        var item = Items[arg.Index];
+        if (string.IsNullOrWhiteSpace(item.Field) && string.IsNullOrWhiteSpace(item.Constant))
         {
-            if (arg == null)
-                return false;
-            var item = Items[arg.Index];
-            if (string.IsNullOrWhiteSpace(item.Field) && string.IsNullOrWhiteSpace(item.Constant))
+            if (item.Key)
             {
-                if (item.Key)
-                {
-                    item.Key = false;
-                    return true;
-                }
-                else
-                {
-                    return false;
-                }
+                item.Key = false;
+                return true;
             }
             else
             {
-                item.Key = !item.Key;
-                return true;
+                return false;
             }
         }
-
-        private BitmapImage? LookupImage(CoreRow? arg)
+        else
         {
-            if (arg == null)
-                return restrict;
+            item.Key = !item.Key;
+            return true;
+        }
+    }
 
-            var item = Items.FirstOrDefault(x => x.Property.Equals(arg.Get<ImportMapping, string>(c => c.Property)));
+    private BitmapImage? LookupImage(CoreRow? arg)
+    {
+        if (arg == null)
+            return restrict;
 
-            if (item == null)
-                return null;
+        var item = Items.FirstOrDefault(x => x.Property.Equals(arg.Get<ImportMapping, string>(c => c.Property)));
 
-            if (string.IsNullOrWhiteSpace(item.Field) && string.IsNullOrWhiteSpace(item.Constant))
-                return null;
+        if (item == null)
+            return null;
 
-            return item.Lookup == ImportLookupType.Create
-                ? create
-                : item.Lookup == ImportLookupType.Restrict
-                    ? restrict
-                    : null;
-        }
+        if (string.IsNullOrWhiteSpace(item.Field) && string.IsNullOrWhiteSpace(item.Constant))
+            return null;
 
-        private bool LookupAction(CoreRow? arg)
-        {
-            if (arg == null)
-                return false;
+        return item.Lookup == ImportLookupType.Create
+            ? create
+            : item.Lookup == ImportLookupType.Restrict
+                ? restrict
+                : null;
+    }
 
-            var property = arg.Get<ImportMapping, string>(c => c.Property);
-            var item = Items.FirstOrDefault(x => x.Property.Equals(property));
+    private bool LookupAction(CoreRow? arg)
+    {
+        if (arg == null)
+            return false;
 
-            if (item == null || (string.IsNullOrWhiteSpace(item.Field) && string.IsNullOrWhiteSpace(item.Constant)))
-                return false;
+        var property = arg.Get<ImportMapping, string>(c => c.Property);
+        var item = Items.FirstOrDefault(x => x.Property.Equals(property));
 
-            if (item.Lookup == ImportLookupType.Restrict)
-                item.Lookup = ImportLookupType.Create;
-            else if (item.Lookup == ImportLookupType.Create)
-                item.Lookup = ImportLookupType.Restrict;
-            else
-                return false;
+        if (item == null || (string.IsNullOrWhiteSpace(item.Field) && string.IsNullOrWhiteSpace(item.Constant)))
+            return false;
 
-            return true;
-        }
+        if (item.Lookup == ImportLookupType.Restrict)
+            item.Lookup = ImportLookupType.Create;
+        else if (item.Lookup == ImportLookupType.Create)
+            item.Lookup = ImportLookupType.Restrict;
+        else
+            return false;
+
+        return true;
     }
 }

+ 0 - 9
inabox.wpf/DynamicGrid/Grids/DynamicItemsListGrid.cs

@@ -41,15 +41,6 @@ public class DynamicItemsListGrid<T> : DynamicGrid<T>, IDynamicItemsListGrid
         set => _items = value as List<T> ?? new List<T>();
     }
 
-    protected override void Init()
-    {
-    }
-
-    protected override void DoReconfigure(DynamicGridOptions options)
-    {
-        
-    }
-
     public override void DeleteItems(params CoreRow[] rows)
     {
         foreach (var row in rows.OrderByDescending(x => x.Index))

+ 0 - 4
inabox.wpf/DynamicGrid/Grids/DynamicManyToManyCrossTab.cs

@@ -43,10 +43,6 @@ public abstract class DynamicManyToManyCrossTab<TManyToMany, TRow, TColumn> : Dy
         HeaderHeight = 125;
     }
 
-    protected override void Init()
-    {
-    }
-
     protected override void DoReconfigure(DynamicGridOptions options)
     {
         options.Clear();

+ 2 - 4
inabox.wpf/DynamicGrid/Grids/DynamicManyToManyGrid.cs

@@ -83,12 +83,10 @@ public class DynamicManyToManyGrid<TManyToMany, TThis> : DynamicGrid<TManyToMany
         ColumnsComponent = new DynamicGridCustomColumnsComponent<TManyToMany>(this, GetTag());
     }
 
-    protected override void Init()
-    {
-    }
-
     protected override void DoReconfigure(DynamicGridOptions options)
     {
+        base.DoReconfigure(options);
+
         options.RecordCount = true;
         options.SelectColumns = true;
         options.MultiSelect = true;

+ 2 - 4
inabox.wpf/DynamicGrid/Grids/DynamicOneToManyGrid.cs

@@ -55,12 +55,10 @@ public class DynamicOneToManyGrid<TOne, TMany> : DynamicGrid<TMany>,
         ColumnsComponent = new DynamicGridCustomColumnsComponent<TMany>(this, GetTag());
     }
 
-    protected override void Init()
-    {
-    }
-
     protected override void DoReconfigure(DynamicGridOptions options)
     {
+        base.DoReconfigure(options);
+
         options.RecordCount = true;
         options.SelectColumns = true;
 

+ 1 - 1
inabox.wpf/DynamicGrid/IDynamicEditorHost.cs

@@ -94,7 +94,7 @@ public class DefaultDynamicEditorHost<T> : IDynamicEditorHost
         var editor = sender.EditorDefinition as ILookupEditor;
         var colname = sender.ColumnName;
 
-        var values = editor.Values(typeof(T), colname, Items);
+        var values = editor.Values(colname, Items);
         sender.LoadLookups(values);
     }