Starting on the FNC Calendar

I have had a quick look at the Guide and the Demo.
This form is grafted on a panel of the mainform.

I was expecting to see something, but the planner collapses to 0 height. Once I can see something, then I can experiment with the properties. The only thing I have changed in the dfm is to align to Client. What am I missing?

pas

unit Ops.Planner.Manage;

interface

uses
  System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
  WEBLib.Forms, WEBLib.Dialogs, VCL.TMSFNCTypes, VCL.TMSFNCUtils,
  VCL.TMSFNCGraphics, VCL.TMSFNCGraphicsTypes, VCL.TMSFNCPlanner,
  VCL.TMSFNCPlannerItemEditorRecurrency, VCL.TMSFNCCustomComponent,
  VCL.TMSFNCPlannerDatabaseAdapter, Vcl.Controls, VCL.TMSFNCCustomControl,
  VCL.TMSFNCPlannerBase, VCL.TMSFNCPlannerData,
  Data.DB, XData.Web.JsonDataset, XData.Web.Dataset, WEBLib.DB,
  Remote.Data,
  Ops.Main;

type
  Tfrm_Planner = class(TWebForm)
    pln_: TTMSFNCPlanner;
    db_ : TTMSFNCPlannerDatabaseAdapter;
    edt_: TTMSFNCPlannerItemEditorRecurrency;
    src_: TWebDataSource;
    xds_: TXDataWebDataSet;

    procedure pln_Click(Sender: TObject);
  private
    procedure Initialise;
    procedure Activate;

    procedure Initialise_Data_Binding;
    procedure Initialise_Timeline;

  public
    class procedure Display;
  end;

implementation

{$R *.dfm}

uses
  PBS.WEB.Common,
  Ops.Planner.Types;

{Tfrm_Planner }

class procedure Tfrm_Planner.Display;

  procedure After_Create (AForm : TObject);
  begin
    Tfrm_Planner(AForm).Initialise;
  end;

begin
  frm_Ops_Main.Show_Form (Tfrm_Planner, @After_Create);
end;

procedure Tfrm_Planner.Initialise;
begin
  pln_.BeginUpdate;
  Initialise_Timeline;
  pln_.EndUpdate;
  Initialise_Data_Binding;
  Activate;
end;

procedure Tfrm_Planner.Activate;
begin
  pln_.Enabled := True;
  db_.LoadItems;
  pln_.Visible := True;
end;

procedure Tfrm_Planner.Initialise_Data_Binding;
begin
  with db_
  do begin
     Item.DataSource := src_;
     Item.DBKey      := fld_Ref;
     Item.Title      := fld_Subject;
     Item.Text       := fld_Summary;
     Item.StartTime  :=  DateToStr (Now);
     Item.EndTime    :=  DateToStr (Now+1);
  end;
end;

procedure Tfrm_Planner.Initialise_Timeline;
begin
  with pln_
  do begin
     Mode                     := pmMultiDay;
     ModeSettings.StartTime   := Now;
     Positions.Count          := 7;
     Timeline.DisplayUnit     := 15;
     Timeline.DisplayUnitType := pduMinute;
     Timeline.DisplayStart    := 0;
     Timeline.DisplayEnd      := 143;
     Timeline.ViewStart       := Now;
  end;
end;

procedure Tfrm_Planner.pln_Click(Sender: TObject);
begin
  TConsole.Log ('Clicked');
end;

end.

Comparing with the demo, I finally assigned FormContainer and it sprung to life.

I see that none of my forms (master or children have it assigned.

Next problem. I have set the Formcontainer to a div with id div.planner. But at render this id gets changed to main.webpanel, so the span breaks out of the div (I guess because it cant find the id). Worse now there are two elements with the same id. I dont have any code that changes the id.

The planner form is getting grafted to main.webpanel that resides on the mainform. This id is getting assigned to the inner div.

Any ideas on how I can fix this? I have tried nested divs, rows etc. No matter what I do the span becomes a sibling of the formcontainer.

object frm_Planner: Tfrm_Planner
  Width = 640
  Height = 480
  CSSLibrary = cssBootstrap
  ElementFont = efCSS
  FormContainer = 'div.planner'
  object pln_: TTMSFNCPlanner
    Left = 0
    Top = 0
    Width = 640
    Height = 480
    Align = alClient
    ParentDoubleBuffered = False
    Color = 16380654
    DoubleBuffered = True
    TabOrder = 0

The html for the form is

<div id="div.planner" class="planner">
</div>

Rendered html

<div id="main.webpanel" zindex="0" style="outline: none;">
<div id="main.webpanel" class="planner" zindex="0" style="">
</div>

<span id="Tfrm_Planner_TMSFNCPlanner3" zindex="0" tabindex="1" role="" style="color: rgb(0, 0, 0); overflow: hidden; outline: none; top: 0px; left: 0px; width: 1920px; height: 731px; position: absolute; box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: transparent; background-color: rgb(238, 242, 249); font-family: Arial; font-style: normal; font-size: 8pt;"><canvas id="Tfrm_Planner_TMSFNCPlanner3_Canvas" zindex="-1" height="731" width="1920" style="position: absolute; height: 731px; width: 1920px;"></canvas><span id="Tfrm_Planner_ScrollBar4" zindex="0" tabindex="1" role="" style="color: rgb(0, 0, 0); outline: none; top: 51px; left: 1902px; width: 17px; height: 679px; position: absolute; box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: transparent; font-family: Arial; font-style: normal; font-size: 8pt; overflow-x: hidden;"><span id="Tfrm_Planner_ScrollBarContent5" zindex="0" tabindex="1" role="" style="color: rgb(0, 0, 0); overflow: hidden; outline: none; top: 0px; left: 0px; width: 17px; height: 2393px; position: absolute; box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: transparent; font-family: Arial; font-style: normal; font-size: 8pt;"></span></span><canvas id="Tfrm_Planner_TMSFNCPlannerDatabaseAdapter8" zindex="0" height="26" width="26" tabindex="1" style="position: absolute; height: 26px; width: 26px; display: none; color: rgb(0, 0, 0); overflow: hidden; outline: none; top: 48px; left: 144px; box-sizing: border-box; user-select: none; -webkit-tap-highlight-color: transparent; font-family: Arial; font-style: normal; font-size: 8pt;" role=""></canvas>
</span>
</div>

Please try to isolate this and provide a sample source project with which this can be reproduced.
Where is 'main.webpanel" coming from? Is this really the main form, do you host the form with Planner in another form, or is it a popup form, etc etc..
There are so many details that can affect what you see that without having any knowledge about what exactly you are doing, it is impossible to investigate.

index.html (908 Bytes)
Ops.Main.dfm (1.3 KB)
Ops.Main.html (417 Bytes)
Ops.Main.pas (1.5 KB)
Ops.Planner.Manage.dfm (22.0 KB)
Ops.Planner.Manage.html (183 Bytes)
Ops.Planner.Manage.pas (1.5 KB)
FNCPLanner_Bug.dpr (406 Bytes)
FNCPLanner_Bug.dproj (62.8 KB)

I cant upload the css files, but the issue is still there.

Click on the planner menu

Inspect the Elements

  • You will spot the div that changes it's id to main.webpanel from form.planner as it has class="planner"
  • 2nd, the span for the planner is outside the div. So I cant position it
  1. You can drop ZIP files here, that makes it possible to have CSS files included and is just one click for me to download your project instead of 8 clicks.
  2. I do not understand where you get the construct to create the form that is supposed to be loaded into an existing HTML element. The demo under Demo\Basics\FormHosting shows how this is done, i.e.
    Tfrm_Planner.CreateNew(Grafted_Id, ...);
    When I use this construct as demonstrated in the demo, the new form sits under main.webplanel and the DIV element with ID form.planner is put under it.
  3. You set TMSFNCPlanner.Align = alClient, in other words, you expect it to align to a DIV in which it is hosted, but this DIV has no size, hence, when the TMSFNCPlanner aligns to an element with no size, it becomes width=0, height=0, hence it is not visible.

Although this project seems to be named TMSFNCPlanner_Bug, I can not see a bug in our control, only incorrect approaches to create a new form and host a Planner in it.

Hi Bruno,

I recall that I had issues with event timing so, I had gone to Application.Create. Which has been working fine for 60 odd forms.

I know now, how the events are different between the two methods and I can change over.

I did that for the sample project and changed some names to match the demo.

This time, the div ID did not change to the panel, which is great.

However I really need the span for the planner to be inside the div.planner. Its always a sibling.

  • I have form.formcontainer = div.planner and the planner (span) is inside it.
  • But at render, the planner is always a sibling of the form (div.planner).

Is there a simple way to fix it ?

  • I did notice that if I place another div
    • div.form_container -> div.planner -> planner (span)
    • then the span is still a sibling of the inner div. But it is inside the form's div. I could possibly work this way.

Also figured out that the site wont accept a rar file. Be default, that's what I use. But the site will accept a zip file.

FNCPlanner.zip (64.8 KB)

Finally figured it out.

When I first placed the planner on TWebPanel, I made it align=client and couldn't see anything.

So, I copied all the demo properties and assigned the FormContainer property. And thats making that div become a sibling.

:man_facepalming:

Thanks for informing a solution was found