Load template and assign datasets in runtime

edited 5:58PM in FastReport 4.0
I have template RozpisObjednavekOdberatelu.fr3 (attachment).I loaded in code this template and assign datasets with this pieces of code:
procedure TTemplateReporter.Preview;
begin
  ReAssignDatasets;
  PrepareReport(False);
  ShowPreparedReport;
end;

procedure TTemplateReporter.ReAssignDatasets;
begin
  DatasetsDictionary.ForEach(
    procedure(const pDS:TPair<string,TDataset>)
    begin
      AssignDataset(pDS.Key,pDS.Value);
    end
  );
end;

procedure TTemplateReporter.AssignDataset(const pReportDSName: string; const
    pDataSet: TDataSet);
var
  lRDS: TfrxDBDataset;
begin
  lRDS:=FastRep.FindObject(pReportDSName) as TfrxDBDataset;
  if Assigned(lRDS) then
  begin
    lRDS.CloseDataSource:=False;
    lRDS.DataSet:=pDataSet;
  end;
end;
And dictionary filled with datasets in runtime (attached XML from TClientDataset:StitekReportDS.xml,TabulkaReportDS.xml,PatickaReportDS.xml)
procedure TRozpisObjednavekHandler.AssignDatasets;
begin
  DatasetsDictionary.AddOrSetValue('StitekReportDS',StitekDataCDS);
  DatasetsDictionary.AddOrSetValue('TabulkaReportDS',TabulkaDataCDS);
  DatasetsDictionary.AddOrSetValue('PatickaReportDS',PatickaDataCDS);
end;
In XML files data exist OK but when use ShowPrepareReport I got page without any MasterData,why?

Preview result is in RozpisObjednavekOdberatelu.jpg

Please help me with this.

Comments

  • gpigpi
    edited 5:58PM
    Try
    procedure TTemplateReporter.Preview;
    begin
      ReAssignDatasets;
      //Reload your report template again here
      PrepareReport(False);
      ShowPreparedReport;
    end;
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.