Hello all,
My first project with the Planner Component, learning a lot and very excited to use it. I am using it to display Geo location data on pool service tech's so all appointments are in the past (at least 1/2 hour). When opening any of the appointments in any of the supplied editors, selecting OK deletes the item. Selecting Cancel does not.
How do I keep this from happening?
Thanks
Gary
I would really need more information.
I assume this is the non DB-aware TPlanner?
What is the PlannerMode?
What exact information are you editing in the item?
Only reason that I can think of for the item to disappear is that you edit the time to a new time value that is outside the displayed time span of the Planner?
The planner is in day mode and is non data aware. The users do not add or edit items. The planner is used to track geo locations of pool service tech's. The data comes from a downloaded .csv report file that it integrated into our database. The combined information is displayed in one tab of a page control where the user can manipulate (Filter) it. A dictionary of custom item's is generated that is finally loaded into the planner. The data currently is only for a single day, updated by our server downloading the report at selectable intervals, or from previously saved single day reports. The sidebar is positioned to top. Each position represents a Vehicle, and items are stops reported by the Geo service with Display unit set to 5. The Item text contains specific information about the stop.
Some stops (Chemical only) can take as little as 5 min. or less, so the Item text cannot be seen in the planner. The editor is used to display the item so the user can see all the info, not to edit it. I did try to set it to read only, but as expected no editor will display in read only mode.
From a different post I tried added Abort to the OnDelete Event but that didn't help. I tried different editors as well.
The problem is that without editing the info at all, selecting OK in the editor deletes the item. I can always reload the info as it is never touched. The temp solution I am working on is to simply use my own dialog to display the info, but it would have been so much easier to use the supplied editor.
Here is the loading code:
procedure TfrmLocations.LoadPlanner;
var
lPlannerItem: TPlannerItem;
lPsPlannerItemPair: TPsPlannerItemPair;
lItemCount, lProgress: Integer;
begin
FDate := FViewModel.Date;
FCanceled := False;
actCancelRefresh.Visible := True;
actCancelRefresh.Enabled := True;
plnrMain.Visible := False;
try
plnrMain.Display.BeginUpdate;
try
lItemCount := FViewModel.PlannerItemsCount;
lProgress := 1;
gpProgress.Max := lItemCount;
for lPsPlannerItemPair in FViewModel.PlannerItems do
begin
if lProgress mod 50 = 0 then
Application.ProcessMessages;
if FCanceled then
Exit;
lPlannerItem := plnrMain.CreateItem;
lPlannerItem.ItemStartTime := lPsPlannerItemPair.Value.BeginStop;
lPlannerItem.ItemEndTime := lPsPlannerItemPair.Value.EndStop;
lPlannerItem.ItemPos := lPsPlannerItemPair.Value.Position - 1;
if lPsPlannerItemPair.Value.StopType = stStartDay then
begin
plnrMain.PositionProps[lPlannerItem.ItemPos].ActiveStart :=
lPlannerItem.ItemBegin;
plnrMain.PositionProps[lPlannerItem.ItemPos].ActiveEnd :=
plnrMain.PositionProps[lPlannerItem.ItemPos].ActiveStart + 112;
end;
lPlannerItem.CaptionText := lPsPlannerItemPair.Value.PlaceID;
if lPsPlannerItemPair.Value.CaptionBkg <> DEFAULT_BK_COLOR then
lPlannerItem.CaptionBkg := lPsPlannerItemPair.Value.CaptionBkg;
if lPsPlannerItemPair.Value.CaptionFontColor <> DEFAULT_CAPTION_FONT_COLOR
then
lPlannerItem.CaptionFont.Color :=
lPsPlannerItemPair.Value.CaptionFontColor;
lPlannerItem.url := lPlannerItem.url +
lPsPlannerItemPair.Value.PlannerItemURL;
lPlannerItem.Text.Add(lPsPlannerItemPair.Value.StreetAddress);
lPlannerItem.Text.Add('Stop Length: ' +
lPsPlannerItemPair.Value.StopLength);
lPlannerItem.Text.Add('Idle Time: ' +
lPsPlannerItemPair.Value.IdleTime);
lPlannerItem.Tag := lPsPlannerItemPair.Value.Tag;
gpProgress.Position := lProgress;
Inc(lProgress);
end;
finally
plnrMain.Display.EndUpdate;
end;
finally
plnrMain.Visible := True;
actCancelRefresh.Visible := False;
actCancelRefresh.Enabled := False;
FCanceled := False;
end;
end;
The planner itself is on a page control page on a frame that is created at runtime and parented to a panel on the main form that can Show/Hide by toggle button setting Visible / sendTo Front/Back, so it doesn't have to be rendered each time it is shown as the rest of the apps frames are. As the day progresses or a completed history day are loaded there can be over 500 items, and loading is slow.
Here is a screen shot:
The Items do have events set. The Item URL is set to google maps + Longitude Latitude of stop, and double Click opens the customers detail page
What are your settings under Planner.Mode?
I retested this here with default settings and I could not see such problem with the built-in item editors.
plnrMain.Mode.PlannerType := plDay;
plnrMain.Mode.Day := FDate.GetDay;
plnrMain.Mode.Month := FDate.GetMonth;
plnrMain.Mode.PeriodEndDay := FDate.GetDay;
plnrMain.Mode.PeriodEndMonth := FDate.GetMonth;
plnrMain.Mode.PeriodEndYear := FDate.GetYear;
plnrMain.Mode.PeriodStartDay := FDate.GetDay;
plnrMain.Mode.PeriodStartMonth := FDate.GetMonth;
plnrMain.Mode.PeriodStartYear := FDate.GetYear;
plnrMain.Mode.TimeLineStart := FDate;
plnrMain.Mode.WeekStart := FDate.GetWeek;
plnrMain.Mode.Year := FDate.GetYear;
I just ran it.
Logging:
TfrmLocations.LoadPlanner
Date: 2/9/2023
plnrMain.Mode.Day: 9
plnrMain.Mode.Month: 2
plnrMain.Mode.PeriodEndDay: 9
plnrMain.Mode.PeriodEndMonth: 2
plnrMain.Mode.PeriodEndYear: 2023
plnrMain.Mode.PeriodStartDay: 9
plnrMain.Mode.PeriodStartMonth: 2
plnrMain.Mode.PeriodStartYear: 2023
Main.Mode.TimeLineStart: 9
plnrMain.Mode.WeekStart: 6
plnrMain.Mode.Year: 2023
TfrmLocations.LoadPlanner
I only paid attention to the Planner type, so the additional settings in Mode were just added, but still deletes
With your setup, I setup a test project, attached here, with which I cannot reproduce this.
Project1.zip (54.1 KB)