Browse Source

Added new UpdateCell() function

Kenric Nugteren 7 months ago
parent
commit
a1d482d9d4

+ 5 - 0
inabox.wpf/DynamicGrid/DynamicGrid.cs

@@ -799,6 +799,11 @@ public abstract class DynamicGrid<T> : DynamicGrid, IDynamicGridUIComponentParen
         UIComponent.UpdateCell(coreRow, colname, value);
     }
 
+    protected void UpdateCell(CoreRow row, DynamicColumnBase column)
+    {
+        UIComponent.UpdateCell(row, column);
+    }
+
     private void EntityChanged(T obj, CoreRow row, string changedColumn, Dictionary<string, object?> changes)
     {
         OnAfterEditorValueChanged(null, [obj], new AfterEditorValueChangedArgs(changedColumn, changes), changes);

+ 19 - 0
inabox.wpf/DynamicGrid/UIComponent/DynamicGridGridUIComponent.cs

@@ -4,6 +4,7 @@ using InABox.Scripting;
 using InABox.Wpf;
 using InABox.WPF;
 using org.omg.PortableInterceptor;
+using sun.util.resources.cldr.fr;
 using Syncfusion.Data;
 using Syncfusion.Data.Extensions;
 using Syncfusion.UI.Xaml.Grid;
@@ -1457,6 +1458,24 @@ public class DynamicGridGridUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
             dataRow[datacolname] = value ?? DBNull.Value;
         }
     }
+    void IDynamicGridUIComponent<T>.UpdateCell(CoreRow row, DynamicColumnBase column)
+    {
+        var dataRow = GetDataRow(row);
+        if(dataRow is not null)
+        {
+            if(column is DynamicGridColumn gc)
+            {
+                var dataColName = gc.ColumnName.Replace(".", "_");
+
+                dataRow[dataColName] = row[gc.ColumnName] ?? DBNull.Value;
+            }
+            else if(column is DynamicActionColumn ac)
+            {
+                var i = ActionColumns.IndexOf(ac);
+                dataRow[$"ActionColumn{i}"] = ac.Data(row);
+            }
+        }
+    }
 
     void UpdateRow(CoreRow row, DataRow dataRow)
     {

+ 17 - 0
inabox.wpf/DynamicGrid/UIComponent/DynamicGridTreeUIComponent.cs

@@ -1243,6 +1243,23 @@ public class DynamicGridTreeUIComponent<T> : IDynamicGridUIComponent<T>, IDynami
             node.InvalidateData();
         }
     }
+    public void UpdateCell(CoreRow row, DynamicColumnBase column)
+    {
+
+        var node = GetNode(row);
+        if(node is not null)
+        {
+            if(column is DynamicGridColumn gc)
+            {
+                node[gc.ColumnName] = row[gc.ColumnName];
+            }
+            else if(column is DynamicActionColumn ac)
+            {
+                var i = ActionColumns.IndexOf(ac);
+                node[$"_ActionColumn{i}"] = ac.Data(row);
+            }
+        }
+    }
 
     public void UpdateRow(CoreRow row)
     {

+ 1 - 0
inabox.wpf/DynamicGrid/UIComponent/IDynamicGridUIComponent.cs

@@ -68,6 +68,7 @@ public interface IDynamicGridUIComponent<T>
 
     void UpdateRow(CoreRow row);
     void UpdateCell(CoreRow row, string column, object? value);
+    void UpdateCell(CoreRow row, DynamicColumnBase column);
 
     void AddVisualFilter(string column, string value, FilterType filtertype = FilterType.Contains);
     List<Tuple<string, Func<CoreRow, bool>>> GetFilterPredicates();