AfterOpen event on master/detail

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
brant
Posts: 3
Joined: Fri 18 Jan 2013 16:14

AfterOpen event on master/detail

Post by brant » Fri 18 Jan 2013 18:33

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).
Last edited by brant on Thu 31 Jan 2013 13:06, edited 1 time in total.

AndreyZ

Re: AfterOpen event on master/detail

Post by AndreyZ » Mon 21 Jan 2013 12:37

Thank you for the information. We will investigate this problem.
As a workaround, you can use the AfterExecute event.

brant
Posts: 3
Joined: Fri 18 Jan 2013 16:14

Re: AfterOpen event on master/detail

Post by brant » Thu 24 Jan 2013 17:45

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:

AndreyZ

Re: AfterOpen event on master/detail

Post by AndreyZ » Fri 25 Jan 2013 11:56

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;

brant
Posts: 3
Joined: Fri 18 Jan 2013 16:14

Re: AfterOpen event on master/detail

Post by brant » Thu 31 Jan 2013 11:58

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;

AndreyZ

Re: AfterOpen event on master/detail

Post by AndreyZ » Mon 15 Jul 2013 12:49

We have added the call of the AfterOpen event. This functionality will be available in the next UniDAC version.

Post Reply