Page 1 of 1

AfterOpen event on master/detail

Posted: Fri 18 Jan 2013 18:33
by brant
I have a simple master/detail relationship using 2 TUniQuery components.

I noted that the AfterOpen event of the detail query is triggered only once, on the opening of the query. Afterwards, when we scroll over the master records the detail records are shown but the detail's AfterOpen event is not triggered anymore. With the monitor I can see that the detail query is open each time we scroll over the master.

I expected that this event be triggered each time the master scrolls, as the detail dataset is open again. :(

Is there any way to enable this? This was the normal way BDE TQuery component works.

ps. I'm using the version 4.1.4 and tested also with trial version 4.6.11 (Delphi7).

Re: AfterOpen event on master/detail

Posted: Mon 21 Jan 2013 12:37
by AndreyZ
Thank you for the information. We will investigate this problem.
As a workaround, you can use the AfterExecute event.

Re: AfterOpen event on master/detail

Posted: Thu 24 Jan 2013 17:45
by brant
So, when converting old BDE programs do Unidac you recommend changing all AfterOpen events of details to AfterExecute events?

In this case one additional problem is that the event prototype is different and do not have the DataSet parameter that is used very often:

procedure TUnidac02.uniDetailQueryAfterOpen(DataSet: TDataSet);
procedure TUnidac02.uniDetailQueryAfterExecute(Sender: TObject; Result: Boolean); :cry:

Re: AfterOpen event on master/detail

Posted: Fri 25 Jan 2013 11:56
by AndreyZ
You can use the following code:

Code: Select all

procedure TUnidac02.uniDetailQueryAfterExecute(Sender: TObject; Result: Boolean);
var
  DataSet: TDataSet;
begin
  DataSet := TDataSet(Sender);
  // other code
end;

Re: AfterOpen event on master/detail

Posted: Thu 31 Jan 2013 11:58
by brant
After some tests we concluded that to accurately emulate BDE's behavior (when migrating programs) you should do the following changes if you have AfterOpen and/or BeforeOpen events e Detail queries:

- transfer your old code in the AfterOpen event to AfterRefresh event
- transfer your old code in the BeforeOpen event to BeforeRefresh event
- create a new AfterOpen event with some code like this:

Code: Select all

procedure TMyForm.qryDetailxxxAfterOpen(DataSet: TDataSet);
begin
  DataSet.AfterRefresh(DataSet);
end;
- create a new BeforeOpen event with some code like this:

Code: Select all

procedure TMyForm.qryDetailxxxBeforeOpen(DataSet: TDataSet);
begin
  DataSet.BeforeRefresh(DataSet);
end;

Re: AfterOpen event on master/detail

Posted: Mon 15 Jul 2013 12:49
by AndreyZ
We have added the call of the AfterOpen event. This functionality will be available in the next UniDAC version.