using System; using System.Threading; using Comal.Classes; using InABox.Core; using InABox.DynamicGrid; namespace PRSDesktop; public class JobScopeFormGrid : DynamicEntityFormGrid, IJobScopeGrid { public JobScope? Scope { get; set; } private readonly Column ScopeColumn = new Column(x => x.JobScope); public JobScopeFormGrid(Job job): base(job) { } protected override void CustomiseEditor(JobForm[] items, DynamicGridColumn column, BaseEditor editor) { base.CustomiseEditor(items, column, editor); if(ScopeColumn.IsEqualTo(column.ColumnName) || ScopeColumn.IsParentOf(column.ColumnName)) { editor.Editable = Editable.Hidden; } } protected override void DoReconfigure(DynamicGridOptions options) { base.DoReconfigure(options); options.AddRows = false; } protected override void Reload( Filters criteria, Columns columns, ref SortOrder? sort, CancellationToken token, Action action) { if ((Scope == null) || (Scope.ID == Guid.Empty)) criteria.Add(new Filter(x => x.ID).None()); else criteria.Add(new Filter(x => x.JobScope.ID).IsEqualTo(Scope.ID)); base.Reload(criteria, columns, ref sort, token, action); } }