CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Simulating Clicking TIWCGJQDialog button

by ScottWGast » 07 Jun 2016 15:40

I'm trying to "click" the Save button on "myDialog" from within the CGFrame that resides on the dialog:
I call Self.SimulateSaveButtonClick from a button that resides on the CGFrame:

Code: Select all
procedure TframeEditContactContract.SimulateSaveButtonClick;
var
  i: Integer;
begin
  for i := 0 to Self.myDialog.JQDialogOptions.Buttons.Count - 1 do
    if (Self.myDialog.JQDialogOptions.Buttons[i].Text = Include.C_DIALOG_BUTTON_CAPTION_SAVE) then
      Self.myDialog.JQDialogOptions.Buttons[i].OnClick;
end;


This is the event attached to the dialog's "Save" button OnClick.OnEvent:
Code: Select all
procedure TframeEditContact.CloseModalDialog(Sender: TObject; AParams: TStringList);
var
  dialogPopup: TIWCGJQDialog;
  buttonDialog: TIWCGJQCustomDialogButton;
  ctChildType: TContactChildDataType;
  i: Integer;
begin

  // This event is used to close the popup/modal dialog.  It does not matter which button (Cancel or Save) is clicked
  buttonDialog := (Sender AS TIWCGJQCustomDialogButton);

  i := AParams.IndexOfName('ComponentName');
  dialogPopup := TIWCGJQDialog(AParams.Objects[i]);

  ctChildType := TContactChildDataType(dialogPopup.Tag);

  case ctChildType of
    ctContactAddress:
      begin
        if (buttonDialog.Text = Include.C_DIALOG_BUTTON_CAPTION_SAVE) then
          Self.FframeEditContactAddress.SaveData
        else
          Self.FframeEditContactAddress.CancelData;

        Self.FframeEditContactAddress.UnInitialize;
        Self.RefreshGrid(Self.gridAddresses);
      end;
    ctContactContract:
      begin
        if (buttonDialog.Text = Include.C_DIALOG_BUTTON_CAPTION_SAVE) then
          Self.FframeEditContactContract.SaveData
        else
          Self.FframeEditContactContract.CancelData;

        Self.FframeEditContactContract.UnInitialize;
        Self.RefreshGrid(Self.gridContracts);
      end;
    ctLinkedDocument:
      begin
        if (buttonDialog.Text = Include.C_DIALOG_BUTTON_CAPTION_SAVE) then
          Self.FframeEditContactLinkedDocument.SaveData
        else
          Self.FframeEditContactLinkedDocument.CancelData;

        Self.FframeEditContactLinkedDocument.UnInitialize;
        Self.RefreshGrid(Self.gridLinkedDocuments);
      end;
  end;

  dialogPopup.JQDialogOptions.Close(False);
end;


Any clue as to why the dialog is not closing? Everything works great if I actually click the "Save" button.

Thanks!
Scott
ScottWGast
 
Posts: 875
Joined: 23 May 2012 11:02

by Alexander Bulei » 07 Jun 2016 17:23

Hi Scott,

Self.myDialog.JQDialogOptions.Buttons[i].OnClick;


It will trigger the delphi code only and will not interact with UI on client side.

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 ScottWGast » 07 Jun 2016 17:26

Thanks Alexander, I guessed as much.

I'll work around it!

Scott
ScottWGast
 
Posts: 875
Joined: 23 May 2012 11:02


Return to JQDialog

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.