BaseIntegrationGrid.cs 1.6 KB

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