Loading detail dataset just in time by master id.
Hello,
We a have master-detail report (with master and detail dataset). Is there any event in FastReport suitable to load detail dataset just in time by id of master dataset in master databand. Is possible to use this approach here?
Thanx
We a have master-detail report (with master and detail dataset). Is there any event in FastReport suitable to load detail dataset just in time by id of master dataset in master databand. Is possible to use this approach here?
Thanx
Comments
Both master and detail datasources must be filled before you run a report. There is no event to fill the detail datasource when the master current row changes.
Hi Jon,
This code works for me:
Kind Regards,
Keith Blows
If your datasource is sql-based, you may set up query parameters. For example:
Master query ("Customers"):
Detail query ("Orders"):
the "custid" parameter is defined in the following way:
For example We have a dataset CustOrd with datatables Customers and Orders.
Datatable Custommers is assigned to DataBand MasterDataCustomer
Datatable Order is assigned to DataBand MasterDataOrder. Orders is detail of Custommes. Order is connected to Customers by foreign key Custommer_ID
We would like load Orders for every custommer just in time from Db by SQL statement with Custommer_ID foreign key parameter.
We can get ID_Custommer in MasterDataCustomer_beforePrint method.
We can load datatable Order from sql DB by Custommer_ID foreign key for every Custommers row in MasterDataCustomer_beforePrint .
We dont know how to register data from Order table.
We try call Ordes select with Custommer_ID = 0 on start to create empty datatable. In MasterDataCustomer_beforePrint are created datatables by selects Orders with Custommer id.
When I register data on start, I can see only datasource corresponding to empty datatable in Design.
When I register data in Custommers_beforePrint method, there is posible to see a lots new Orders datasources for every Customer iteration. Every datatasource has any generated name.
We would need one datasource where we could replace data by reassign a new datatable in MasterDataCustomer_beforePrint method.
Is it possible? Is there any way how assign to Order datasource a new Order Datatable for every Custommer iteration in MasterDataCustomer_beforePrint method?
Thanx
Ok, I will add the event for your case. I will inform you when it will be available (probably tomorrow, in the next daily build).
When a preview is runned from a design window, then detail's Load events are called, but only first time when preview is runned. Is there any option or event to call load events anytime when preview is runned from one design window?
You may subscribe to the Report.StartReport event and move the following code into the event handler:
report_StartReport:
{
DataSourceBase detailDs = report.GetDataSource("detail");
detailDs.Load += new EventHandler(detailDs_Load);
}