CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Creating a dialog at runtime causes dependency issues

by omonien » 13 May 2021 13:19

Hi!

I am creating a dialog at runtime (async button click), which technically works.

There are problems though if there are JQControls on the dialog. Apparently, their dependencies are not resolved correctly. This results in incomplete/missing functionality.

delphi code
procedure TIWForm1.IWCGJQButton1JQButtonOptionsClick(Sender: TObject; AParams: TStringList);
begin
var LDialog := TIWCGJQDialog.Create(self);
LDialog.Name := 'Dialog1';
LDialog.Parent := self;
LDialog.JQDialogOptions.Title := 'Test';

var LDropdown := TIWCGJQDropDown.Create(LDialog);
LDropdown.Parent := LDialog;
LDropDown.Name := 'Dropdown1';
LDialog.Show;
end;


This makes the Dialog show as expected, but the Dropdown misses all of its extended functionality from "select2()". Inspecting the requests, it seems that the required dropdown.js files are not loaded.

Adding LDialog.AjaxReRender; after Ldialog.Show; adds a lot more to the response, including the required js files, which are loaded successfully. Yet, the calls to .select2() still result in errors - probably because they are executed before the js files are loaded.
And the dialog does not show up anymore - probably because the errors break the display process.

Any ideas?
Olaf Monien
Embarcadero MVP Coordinator
www.developer-experts.net
User avatar
omonien
 
Posts: 4
Joined: 25 Feb 2021 15:18

by Alexander Bulei » 13 May 2021 14:29

Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by omonien » 14 May 2021 08:44

Hi Alexander,

thanks for following up.

In that other post, the issue was that the developer forgot to assign Name/Parent to the dialog. In my simplified example code, you can see that I am assigning Owner, Parent, and Name to the dialog and the inner control.

Without AjaxReRender, the dialog shows up, including the dropdown. The dropdown is not functional though, the required call(s) to .select2() (of the underlying JQ widget) seem to bemissing.

If you add an AjaxReRender, then I can see the required drowpdown.js files and calls to .select2() - but the dialog does not show up, likely because of a wrong order (before the js files are loaded?). See screenshot. I can send a trivial demo if you want.

Bildschirmfoto 2021-05-14 um 09.41.57.png
You do not have the required permissions to view the files attached to this post.
Olaf Monien
Embarcadero MVP Coordinator
www.developer-experts.net
User avatar
omonien
 
Posts: 4
Joined: 25 Feb 2021 15:18

by Alexander Bulei » 29 Jun 2021 16:45

Hi,
You always need AjaxReRender if you create the components in runtime, and when use dialog.

So, check the console when you use AjaxReRender.

BR
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by omonien » 30 Jun 2021 07:45

Thanks, I am actually working on a solution, that would call AjaxRerender on all related components, automatically.
Olaf Monien
Embarcadero MVP Coordinator
www.developer-experts.net
User avatar
omonien
 
Posts: 4
Joined: 25 Feb 2021 15:18


Return to JQDialogEx

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.