Page 1 of 1

Simulating Clicking TIWCGJQDialog button

PostPosted: 07 Jun 2016 15:40
by ScottWGast
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

Re: Simulating Clicking TIWCGJQDialog button

PostPosted: 07 Jun 2016 17:23
by Alexander Bulei
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.

Re: Simulating Clicking TIWCGJQDialog button

PostPosted: 07 Jun 2016 17:26
by ScottWGast
Thanks Alexander, I guessed as much.

I'll work around it!

Scott