CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Show modal JQDialog (unit2) over IWForm1 (unit1)

by jorgo » 11 Nov 2016 11:38

Hi,

I have a base IWForm1 which needs over 20 modal JQDialogs.
I don't want them all inside 1 unit.
I don't want over 20 frames inside my base form.
Each dialog should lay in a different unit.

On button click this dialog should be shown modal.
The base form IWForm1 should be blocked.
After release of the modal dialog I want to work again with IWForm1.

Is there an easy example how to do this?

Kind regards
jorgo
 
Posts: 108
Joined: 13 Jul 2016 15:57

by Alexander Bulei » 11 Nov 2016 12:38

Hi jorgo,

Use the File > New -> Other -> CGDevTools -> IWCG Frame

Code: Select all
Frame class type: IWCGJQFrame
Frame Type: IWCGJQDialog


Set the JQDialogOptions.Modal = True

Then, use our method to call them when you need:

delphi code
IsAsync:= CGIsCallBackProcessing;
if IsAsync then
begin
CGCallBackDisableAjaxResponse;
end;
try
// CREATE DIALOG HERE
finally
if IsAsync then
begin
CGCallBackEnableAjaxResponse;
<dialogframe>.AjaxReRender(True,False);
end;
end;


Best Regards.
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 jorgo » 11 Nov 2016 13:11

Hi Alexander,

all is working good except the marked line.

Code: Select all
procedure TIWForm2.IWCGJQButton1JQButtonOptionsClick(Sender: TObject; AParams: TStringList);
var
  IsAsync : boolean;
  myFrame : TIWCGJQFrame4;

begin
  IsAsync:= CGIsCallBackProcessing;

  if IsAsync then
  begin
    CGCallBackDisableAjaxResponse;
  end;

  try
    // CREATE DIALOG HERE
    myFrame := TIWCGJQFrame4.Create(self);
    myFrame.Parent := self;

  finally
    if IsAsync then
    begin
      CGCallBackEnableAjaxResponse;

      //*******************************************************************************************
      <myFrame>.<span class="posthilit">AjaxReRender</span>(True,False);
      //*******************************************************************************************
    end;
  end;
end;


Is this Javascript code?

Kind regards
jorgo
 
Posts: 108
Joined: 13 Jul 2016 15:57

by Alexander Bulei » 11 Nov 2016 13:15

No...

replace with your frame/dialog...

E.g:

Code: Select all
IWCGJQDialog1.AjaxReRender(True,False);


Best Regards.
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 jorgo » 11 Nov 2016 14:48

Hi Alexander,

1.) I wrongly tried to rerender the TIWCGJQFrame and not the TIWCGJQDialog !
Now it's runing.

Code: Select all
myFrame.IWFrameRegion.AjaxReRender(True,False);


2.) How can I close the modal dialog like the "X"?

Calling "Free" inside the modal dialog works only 1 time.
The next creation of it throws exceptions.
With "X" I can close and create it many times.

Kind regards
jorgo
 
Posts: 108
Joined: 13 Jul 2016 15:57

by Alexander Bulei » 11 Nov 2016 14:52

Use JQDialogOptions.OnClose event.
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 jorgo » 11 Nov 2016 16:46

Hi Alexander,

I want to get "JQDialogOptions.OnClose event".
But first I must trigger it.
My modal dialog is of type:

type
TIWCGJQFrame4 = class(TIWCGJQFrame)
IWFrameRegion: TIWCGJQDialog;

I try following to close the modal dialog with a button (positioned on this modal dialog):

Code: Select all
procedure TIWCGJQFrame4.IWCGJQButton1JQButtonOptionsClick(Sender: TObject; AParams: TStringList);
var
   jsCode : string;
begin
   jsCode := 'document.getElementById(''IWCGJQFRAME4'').close();';
   WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(jsCode);

   jsCode := 'document.getElementById(''IWFRAMEREGION'').close();';
   WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA(jsCode);
end;


It's not working
jorgo
 
Posts: 108
Joined: 13 Jul 2016 15:57

by Alexander Bulei » 11 Nov 2016 17:04

You want close it programmatically?

If so, the dialog already have function/API:

Documentation
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 jorgo » 11 Nov 2016 17:31

Hi thx,
now I have a working solution.

Calling form TIWForm2:

Code: Select all
procedure TIWForm2.IWCGJQButton1JQButtonOptionsClick(Sender: TObject; AParams: TStringList);
var
  IsAsync : boolean;
begin
  IsAsync:= CGIsCallBackProcessing;

  if IsAsync then
  begin
    CGCallBackDisableAjaxResponse;
  end;

  try
    if Assigned(UNIT4.myFrameDialog) then
    begin
      UNIT4.myFrameDialog.Free;
      UNIT4.myFrameDialog := NIL;
    end;

    // CREATE DIALOG HERE
    UNIT4.myFrameDialog := TIWCGJQFrame4.Create(self);
    UNIT4.myFrameDialog.Parent := self;

  finally
    if IsAsync then
    begin
      CGCallBackEnableAjaxResponse;
      UNIT4.myFrameDialog.IWFrameRegion.AjaxReRender(True,False);
    end;
  end;
end;


Modal form TIWCGJQFrame4:

Code: Select all
unit Unit4;

interface

uses
  SysUtils,Classes,Controls,IWCGFrame,IWVCLBaseContainer,IWContainer,
  IWHTMLContainer,IWHTML40Container,IWCGJQDialog, IWCGJQButton,
  IWCGJQThemeSwitcher, Vcl.Forms, IWRegion, IWCGJQControl;

type
  TIWCGJQFrame4 = class(TIWCGJQFrame)
    IWFrameRegion: TIWCGJQDialog;
    IWCGJQThemeSwitcher1: TIWCGJQThemeSwitcher;
    IWCGJQButton1: TIWCGJQButton;
    procedure IWCGJQButton1JQButtonOptionsClick(Sender: TObject; AParams: TStringList);
    procedure IWFrameRegionJQDialogOptionsClose(Sender: TObject; AParams: TStringList);
  end;

var
  myFrameDialog : TIWCGJQFrame4;

implementation

{$R *.dfm}

procedure TIWCGJQFrame4.IWCGJQButton1JQButtonOptionsClick(Sender: TObject; AParams: TStringList);
begin
  IWFrameRegion.Visible:= False;
end;

procedure TIWCGJQFrame4.IWFrameRegionJQDialogOptionsClose(Sender: TObject; AParams: TStringList);
begin
  WebApplication.ReleaseForm(Self);
  myFrameDialog := NIL;
end;

initialization
  myFrameDialog := NIL;

end.


Have a nice weekend
jorgo
 
Posts: 108
Joined: 13 Jul 2016 15:57

by Alexander Bulei » 11 Nov 2016 17:32

Great, you too. ;)
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

Next

Return to JQDialogEx

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.