JobProductStylesGrid.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Comal.Classes;
  2. using InABox.Core;
  3. using InABox.DynamicGrid;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PRSDesktop.Panels.Jobs;
  10. public class JobProductStylesGrid : DynamicDataGrid<JobStyle>, IJobControl, IDataModelSource
  11. {
  12. public Job Job { get; set; }
  13. JobPanelSettings IJobControl.Settings { get; set; }
  14. public string SectionName => "Job Product Styles";
  15. public event DataModelUpdateEvent? OnUpdateDataModel;
  16. protected override bool CanCreateItems()
  17. {
  18. return Job.ID != Guid.Empty;
  19. }
  20. protected override JobStyle CreateItem()
  21. {
  22. var result = base.CreateItem();
  23. result.Job.ID = Job.ID;
  24. result.Job.Synchronise(Job);
  25. return result;
  26. }
  27. public DataModel DataModel(Selection selection)
  28. {
  29. var ids = ExtractValues(x => x.ID, selection).ToArray();
  30. return new BaseDataModel<JobStyle>(new Filter<JobStyle>(x => x.ID).InList(ids));
  31. }
  32. protected override void Reload(Filters<JobStyle> criteria, Columns<JobStyle> columns, ref SortOrder<JobStyle>? sort, Action<CoreTable?, Exception?> action)
  33. {
  34. criteria.Add(new Filter<JobStyle>(x => x.Job.ID).IsEqualTo(Job.ID));
  35. base.Reload(criteria, columns, ref sort, action);
  36. }
  37. }