Create own Planner Item Editor?

Hi,

is there an example how I can create an own Editor? Did I have to compile/install the tmsd2010.dpk new to add an Item Editor?

Thanks

Please see the samples

TSimpleItemEditor, TPeriodItemEditor


This class is the interface between the PlannerItem and your custom form you can use to edit:

  TSimpleItemEditor = class(TCustomItemEditor)
  private
    FEditForm: TSimplePlannerItemEditForm;
    FCenter: Boolean;
    FFormLeft: Integer;
    FFormTop: Integer;
  public
    constructor Create(AOwner: TComponent); override;
    procedure CreateEditor(AOwner: TComponent); override;
    procedure DestroyEditor; override;
    function Execute: Integer; override;
    procedure PlannerItemToEdit(APlannerItem: TPlannerItem); override;
    procedure EditToPlannerItem(APlannerItem: TPlannerItem); override;
  published
    property CenterOnScreen: Boolean read FCenter write FCenter default True;
    property FormLeft: Integer read FFormLeft write FFormLeft;
    property FormTop: Integer read FFormTop write FFormTop;
  end;

If you implement an override the public methods, you can use any custom form as inplace editor (similar to samples PlanSimpleEdit.pas, PlanPeriodEdit.pas)

Hi,

thanks for your answer. I've done so, but I got one last question: how can I register MyEditForm to the Planner?

Best regards ...

The Execute method of your editor class is responsible for creating & showing your form.
If you descend from TCustomItemEditor, you can assign this class to PlannerItem.Editor

Hi,

ok. Executing works, but now I got another problem. If I use my Editor, the Item is not updated (If I use no Editor it works correct). My Editor is like the code in #2. The changes of an item are displayed in the item, but there's no update to the database? I register the Editor like:


  public
    ScheduleEditor : TSimpleItemEditor;
  ....
  // OnCreate
  ScheduleEditor := TSimpleItemEditor.Create(self);
  planner.DefaultItem.Editor := ScheduleEditor;
  //OnDestroy
  FreeAndNil(ScheduleEditor);



Best regards ....


Did you implement the override of the method:


procedure EditToPlannerItem(APlannerItem: TPlannerItem); override;

this is responsible for updating the item after editing.

Hi,

yes, it looks:


procedure TSimpleItemEditor.EditToPlannerItem(APlannerItem: TPlannerItem);
begin
  inherited;
  FEditForm.AssignToPlannerItem(APlannerItem);
end;


and


procedure Tdateedit.AssignToPlannerItem(PlannerItem: TPlannerItem);
begin
  PlannerItem.CaptionText       := edSubject.Text;
  PlannerItem.Text              := TStringList(edMemo.Lines);
  PlannerItem.ItemStartTime     := Int(PlanDate.Date) + Frac(StartTime.Time);
  PlannerItem.ItemEndTime       := Int(PlanDate.Date) + Frac(EndTime.Time);
  PlannerItem.ItemRealStartTime := Int(PlanDate.Date) + Frac(StartTime.Time);
  PlannerItem.ItemRealEndTime   := Int(PlanDate.Date) + Frac(EndTime.Time);
end;


and this works, but only to the item. Not to the database!

If I drag and drop the item without using an editor changes to the database are made.

Best regards ...

Call Item.Update after setting the properties.

Hi,

that was simple :-) . Great!

Best regards ...