Browse Source

Made "Entity" on DynamicEntityFormGrid virtual

Kenric Nugteren 6 days ago
parent
commit
2ec7627984
1 changed files with 13 additions and 4 deletions
  1. 13 4
      inabox.wpf/DynamicGrid/DynamicEntityFormGrid.cs

+ 13 - 4
inabox.wpf/DynamicGrid/DynamicEntityFormGrid.cs

@@ -16,12 +16,10 @@ namespace InABox.DynamicGrid
         where TEntity : Entity
         where TEntityLink : IEntityLink<TEntity>, new()
     {
-        private TEntity Entity { get; set; }
+        protected virtual TEntity Entity { get; set; }
 
-        public DynamicEntityFormGrid(TEntity entity)
+        public DynamicEntityFormGrid()
         {
-            Entity = entity;
-
             OnBeforeSave += BeforeSave;
             OnCustomiseEditor += DynamicEntityFormGrid_OnCustomiseEditor;
 
@@ -32,6 +30,11 @@ namespace InABox.DynamicGrid
             HiddenColumns.Add(x => x.Form.ID);
         }
 
+        public DynamicEntityFormGrid(TEntity entity) : this()
+        {
+            Entity = entity;
+        }
+
         private void DynamicEntityFormGrid_OnCustomiseEditor(IDynamicEditorForm sender, TForm[]? items, DynamicGridColumn column, BaseEditor editor)
         {
             if(column.ColumnName == "Form.ID")
@@ -40,6 +43,10 @@ namespace InABox.DynamicGrid
             }
         }
 
+        protected virtual void OnFormCreated(TForm form)
+        {
+        }
+
         protected override void DoAdd(bool OpenEditorOnDirectEdit = false)
         {
             var filter = LookupFactory.DefineChildFilter<TEntity, DigitalForm>(new TEntity[] { Entity })
@@ -65,6 +72,8 @@ namespace InABox.DynamicGrid
 
                     SaveItem(form);
 
+                    OnFormCreated(form);
+
                     Refresh(false, true);
                     DoChanged();
                 }