Hi,
I try to build a planner thanks to DBPlanner (with a TDBDaySource on mode dmMultiResource) and WaitList components.
I build my wait list with 5 Items and for each, I generate a new Guid and put it in DBKey property.
for i := 1 to 5 do
begin
Item := PlannerWaitList.Items.Add();
CreateGUID(Guid);
Item.DBKey := GUIDToString(Guid);;
Item.text.Text := 'Element Initial '+inttostr(i);
Item.itemend := Item.itembegin + i;
Item.PopupMenu := popUpMenuPlanner;
Item.ReadOnly := true;
Item.Editor := DefaultItemEditor1;
end;
After I drag & drop an item onto my Planner, the event OnInsertItem is fired on my TDBDaySource.
Inside this event i collect the infos of my Item (drag dropped) to record my dataset behind my planner) like this :
procedure TFrmPlanningTestDB.DBDaySource1InsertItem(Sender: TObject;
APlannerItem: TPlannerItem);
begin
MemTable1.Insert;
MemTable1.FieldByName('KeyField').AsString := APlannerItem.DBKey;
MemTable1.FieldByName('StartTime').AsDateTime := APlannerItem.ItemStartTime;
MemTable1.FieldByName('EndTime').AsDateTime := APlannerItem.ItemEndTime;
MemTable1.FieldByName('Notes').AsString := APlannerItem.NotesText;
MemTable1.FieldByName('Subject').AsString := APlannerItem.CaptionText;
MemTable1.FieldByName('Color').AsInteger := APlannerItem.Color;
MemTable1.FieldByName('Image').AsInteger := APlannerItem.ImageID;
//MemTable1.FieldByName('ResourceId').AsInteger := position;
if( APlannerItem.CaptionType = ctTime) then
begin
MemTable1.FieldByName('Caption').AsBoolean := True;
end
else
begin
MemTable1.FieldByName('Caption').AsBoolean := False;
end;
MemTable1.Post;
MemTable1.Active := False;
MemTable1.Active := True;
end;
BU my probkem is that the fields APlannerItem.DBKey is not the same as the same item in my wait list.
So it's impossible for me to identify wich item from my wait list is dropped inside my planner.
Have you got an idea?
Thanks.
Unless you implement the event DBDaySource.OnCreateKey, the DBDaySource will create its own unique GUID
Hi Bruno,
Indeed ! thanks.
procedure TFBonRepPlan.DBDaySource1CreateKey(Sender: TObject;
APlannerItem: TPlannerItem; var Key: String);
begin
inherited;
Key := Self.PlannerWaitList.SelectedItem.DBKey;
end;