BaseIntegrationGrid.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Comal.Classes;
  2. using InABox.Core;
  3. using InABox.DynamicGrid;
  4. using System.Linq;
  5. namespace PRSDesktop.Integrations.Common;
  6. public abstract class BaseIntegrationGrid<TType, TEntity,TLink> : DynamicItemsListGrid<TType>
  7. where TType : BaseIntegrationCode<TEntity,TLink>, new()
  8. where TEntity : Entity, IRemotable, IPersistent, new()
  9. where TLink : EntityLink<TEntity>
  10. {
  11. protected override void Init()
  12. {
  13. base.Init();
  14. }
  15. protected override void DoReconfigure(DynamicGridOptions options)
  16. {
  17. base.DoReconfigure(options);
  18. options.AddRows = false;
  19. options.EditRows = false;
  20. options.DeleteRows = false;
  21. options.FilterRows = true;
  22. options.HideDatabaseFilters = true;
  23. options.DirectEdit = true;
  24. options.HideDirectEditButton = true;
  25. options.SelectColumns = true;
  26. options.MultiSelect = true;
  27. }
  28. protected override DynamicGridColumns LoadColumns()
  29. {
  30. var result = new DynamicGridColumns();
  31. result.Add<TType>(x => x.Code, 200, "Code");
  32. result.Add<TType>(x => x.Description, 0, "Description");
  33. result.Add<TType>(x => x.Entity.ID, 200, typeof(TEntity).GetCaption());
  34. return result;
  35. }
  36. protected override BaseEditor CustomiseEditor(DynamicGridColumn column, BaseEditor editor)
  37. {
  38. editor = base.CustomiseEditor(column, editor);
  39. if(new Column<TType>(x => x.Entity.ID).IsEqualTo(column.ColumnName) && editor is CodePopupEditor popup)
  40. popup.CanAdd = Security.CanEdit<TEntity>();
  41. return editor;
  42. }
  43. }