浏览代码

Added "CanCreateItems" overridable check to DynamicGrid

Frank van den Bos 2 年之前
父节点
当前提交
f731c0273f
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      InABox.DynamicGrid/DynamicGrid.cs

+ 9 - 0
InABox.DynamicGrid/DynamicGrid.cs

@@ -2630,6 +2630,11 @@ namespace InABox.DynamicGrid
         {
         }
 
+        protected virtual bool CanCreateItems()
+        {
+            return true;
+        }
+
         private bool AddEditClick(CoreRow[]? rows)
         {
             if (!IsEnabled || bRefreshing)
@@ -2637,6 +2642,10 @@ namespace InABox.DynamicGrid
 
             if (rows == null || !rows.Any())
             {
+                
+                if (!CanCreateItems())
+                    return false;
+                
                 var item = CreateItem();
 
                 // Yea, and this won't work, because we're actually usually showing the description of a linked item,