using System; using System.Collections.Generic; using InABox.Core; using Syncfusion.UI.Xaml.Grid; using Syncfusion.UI.Xaml.TreeGrid; namespace InABox.DynamicGrid; /// /// Unless is used, the editor type must be non-generic. /// public interface IDynamicGridEditorColumn : IDynamicColumnBase { DynamicGridColumn Definition { get; set; } string MappingName { get; } string TreeMappingName { get; } List ExtraColumns { get; } bool VariableWidth { get; } bool VariableHeight { get; } bool Filtered { get; } bool Editable { get; } IDynamicGridSummary? Summary(); GridColumn CreateGridColumn(); TreeGridColumn CreateTreeGridColumn(); void UpdateUIComponent(IDynamicGridGridUIComponent component); } /// /// Indicates that this editor only makes sense in a context with a parent entity. If this interface is used, the editor must have /// a single generic type argument, which is . /// public interface IDynamicGridEditorColumn : IDynamicGridEditorColumn { Func? GetEntity { get; set; } event DynamicColumnEntityChangedEvent? EntityChanged; void DoEntityChanged(String columnname, Dictionary changes); } public static class DynamicGridEditorColumnExtensions { public static void UpdateData(this IDynamicGridEditorColumn column, Dictionary updates) { var entity = column.GetEntity?.Invoke(); if (entity != null) { var changes = new Dictionary(); foreach (var key in updates.Keys) DynamicGridUtils.UpdateEditorValue(new BaseObject[] { entity }, key, updates[key], changes); column.DoEntityChanged(column.Definition.ColumnName, changes); } } }