JobScopeFormGrid.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using Comal.Classes;
  3. using InABox.Core;
  4. using InABox.DynamicGrid;
  5. namespace PRSDesktop;
  6. public class JobScopeFormGrid : DynamicEntityFormGrid<JobForm, Job, JobLink>, IJobScopeGrid
  7. {
  8. public JobScope? Scope { get; set; }
  9. public JobScopeFormGrid(Job job): base(job)
  10. {
  11. }
  12. protected override void CustomiseEditor(JobForm[] items, DynamicGridColumn column, BaseEditor editor)
  13. {
  14. base.CustomiseEditor(items, column, editor);
  15. if(column.ColumnName == nameof(JobForm.JobScope.ID))
  16. {
  17. editor.Editable = Editable.Hidden;
  18. }
  19. }
  20. protected override void DoReconfigure(FluentList<DynamicGridOption> options)
  21. {
  22. base.DoReconfigure(options);
  23. options.Remove(DynamicGridOption.AddRows);
  24. }
  25. protected override void Reload(Filters<JobForm> criteria, Columns<JobForm> columns, ref SortOrder<JobForm>? sort, Action<CoreTable?, Exception?> action)
  26. {
  27. if ((Scope == null) || (Scope.ID == Guid.Empty))
  28. criteria.Add(new Filter<JobForm>(x => x.ID).None());
  29. else
  30. criteria.Add(new Filter<JobForm>(x => x.JobScope.ID).IsEqualTo(Scope.ID));
  31. base.Reload(criteria, columns, ref sort, action);
  32. }
  33. }