08-17-2019, 12:32 AM
(This post was last modified: 08-17-2019, 01:25 PM by Jose Nilton Pace.)
(08-16-2019, 09:06 PM)Jose Nilton Pace Wrote: Hi Leo. Try this:
Code:procedure TfrmBase.IWAppFormCreate(Sender: TObject);
RegisterCallBack('clbkGridSel',
procedure (aParams: TStrings; out aResult: string)
begin
aResult := aParams.Values['Selection'];
end
);
end;
Hi Jose, thanx for your reply.
If you take a closer look, you'll see that I already registered the callback method, but instead of registering an anonymous method, I have registered the method TfrmBase.clbkGridSel;
Anyway, I realized what I was doing wrong.
First, I changed the javascript, to include the call of the callback method, after obtaining the result.
Then, altered a bit the code, since the out parameter was useless in this case.
From this part, assume that the CallBack Method is already registered. From now on, I'll only post the code which I need help with.
Here is the refactored callback method:
Code:
procedure TfrmBase.clbkGridSel(aParams: TStrings);
begin
fGridSelection := aParams.Values['Selection'];
end;
Now, on the AsyncClick event of a button, I call the following method:
Code:
function TfrmBase.GetSelecaoGrid(aHtmlID: string): string;
begin
fGridSelection := '';
WebApplication.
CallBackResponse.
AddJavaScriptToExecute(aHtmlID + 'GetSelected()');
/// here I need to wait for the form class protected field "fGridSelection" to obtain the returned value
result := fGridSelection;
end;
I don't want to reload the form.
So, how do I achieve this?