we are trying to host different forms within a Pagecontrol. Mainmenu is a SideBar linked buttons with TabSheets from Pagecontrol. On some Tabsheets we want to load dynamically Forms like this:
the tRegisterForm is a tWebForm. Clicking the Button it shows on the Browser. But it is not created as Child-Element within the Tabsheet. We have tried to create it with the ElementId of a Webpanel within the Tabsheets but this also does not work. the new form is created directly in "body" as a child and not in defined Parent or ElementId.
To host a TWebForm in another control, this is done with creating it on a HTML element specifying its id. So, in your code, you set this to a webpanel HTML element.
The TTMSFNCPageControlContainer is based on a HTML CANVAS element and you cannot host another element on this CANVAS element.
I would suggest to put a TWebPanel or TWebHTMLSpan or something similar on the TTMSFNCPageControlContainer and then host your form on this control.
I tried to add a tWEbPanel into the Pagecontrols Tabsheet, now tried it with a tWebHtmlSpan (+ set a manual ElementId) into the TabSheet + set Span.Align:=alClient.
Now the Form gets visible but there is a problem with the Sidemenu. In normal, the Pagecontrols / Tabsheets content is moved based on the Sidemenus current size (compact or normal).
the new created form is visible but aligned left to 0, no mather if the Sidemenu is collapsed or expanded.
I cannot see how the SideMenu on the main form would be affected by a hosted form in a TTMSFNCPageControl.
If a problem persists, please try to isolate this and provide a sample source project with which we can reproduce the problem here.
I have changed your SideMenu Demo for showing the problem. run attached Demo and click the various Sidemenu elements. The last one should create the subform and its aligned left behind the Sidemenu SideMenu.zip (5.0 KB)
The specific scenario you suggested has not been tested yet so I'm unable to confirm if this will work as expected for now.
Can you try to create a "placeholder" form then replace the form's content on demand?
We'll have to investigate if this behavior can be improved in a future version of TMS WEB Core.
This was just a suggestion based on your sample project. I'm not fully familiar with the details of your entire application, so it may not be applicable in your specific case. Please consider this as a potential starting point that might need further adaptation to fit your needs.
procedure TForm1.WebFormCreate(Sender: TObject);
var
it: TSideMenuItem;
begin
//...
if not assigned(fSubForm) then begin
fSubForm:=tmySubForm.CreateNew(tabSubForm.ElementID, nil);
fSubForm.Align:=alClient;
// fRegisterForm.Load();
end;
fSubForm.Show();
it := WebSideMenu1.Items.Add;
it.Text := 'Subform in Tab';
it.Enabled := true;
it.MaterialGlyph := 'highlight_off';
it.ContentControl := tabSubForm;
it.OnClick:=@OpenSubform;
//...
end;
procedure TForm1.OpenSubform(Sender:tObject);
var
p: TWebPanel;
begin
p := TWebPanel(fSubForm.FindComponent('WebPanel1'));
if Assigned(p) then
begin
p.Caption := 'updated';
end;
end;