[Lazarus] Master-detail-subdetail

Koenraad Lelong lazarus1 at de-brouwerij.be
Fri Jan 7 08:29:31 CET 2011


Op 04-01-11 16:18, michael.vancanneyt at wisa.be schreef:
> 
> 
> On Tue, 4 Jan 2011, Koenraad Lelong wrote:
> 
>> Hi,
>>
>> I have a database (firebird) with master-data, detail-data and
>> sub-detail-data.
>> In lazarus 0.9.28.2, svn 22279, I defined a TIBConnection, a
>> TSQLTransaction and three TSQLQuery's. The detail has as its datasource
>> a datasource coupled with the master. The subdetail has as its
>> datasource a datasource coupled with the detail.
>> To show the data I have three TDBGrids, their datasources are those
>> three datasources coupled with the three queries.
>>
>> When I start the application, the master that shows has several details,
>> each having several sub-details. When I scroll the details, the
>> subdetails follow the detail. That's good. But when I scroll the master,
>> only the details follow, the subdetail-grid goes blank.
>>
>> To try finding what happens I added a button that opens the
>> sub-detail-query. If I click on it I get the expected subdetails. When I
>> scroll the master again, the subdetail disappears again. Again I can get
>> it back by clicking my debug-button.
>>
>> To debug this further, I added events for beforescroll, afterscroll,
>> beforeclose and beforeopen for all three queries which write to a
>> logfile. It seems that the beforeclose event is not fired for the
>> subdetail-query, although it is closed somehow.
>>
>> I hope this makes sense to someone. Is there anything I'm missing ? Or
>> have I found a bug ?
> 
> There is no principle difference between the master/detail and the
> detail/subdetail relation, so I'd expect your setup to work.
> 
> Can you check whether the AfterScroll events occur for
> master/detail/subdetail ?
> 
Hi,
Sorry that it took some time to respond.
Some explanation of the logfile :
In the application I added some code to include text in the logfile
explaining what's hapening.
In the events (beforeOpen, BeforeClose, AfterScroll) I checked which
tables are open : P for table Printen, S for table Staffels and W for
table DefWerktijden. When you see the letter the table is open, if not
the table is closed.
I added two buttons to my application to insert some text in the
logfile. First one to indicate the start of a scroll action in the
detailgrid : "Before scrolling detail". Second one to indicate the start
of a scroll in the mastergrid :"Before scrolling master".
A third button is used to open the subdetail-table manually, text :
opening sub-detail table.

This is the logfile :

Opening Tables
BeforeOpen qryPrinten:___
AfterScroll qryPrinten:P__
BeforeOpen qryStaffels:P__
AfterScroll qryStaffels:PS_
BeforeOpen qryDefWerktijden:PS_
AfterScroll qryDefWerktijden:PSW
Tables open
Before scrolling detail
BeforeScroll qryStaffels:PSW
BeforeOpen qryDefWerktijden:PS_
AfterScroll qryDefWerktijden:PSW
AfterScroll qryStaffels:PSW
before scrolling master
BeforeScroll qryPrinten:PSW
BeforeClose qryStaffels:PSW
BeforeOpen qryStaffels:P__
AfterScroll qryStaffels:PS_
AfterScroll qryPrinten:PS_
opening sub-detail table
BeforeOpen qryDefWerktijden:PS_
AfterScroll qryDefWerktijden:PSW

If there is anything more I can do please ask for it.
Is there some "public" firebird-database I can use to make a sample
application ?

Kind regards,

Koenraad Lelong.




More information about the Lazarus mailing list