Problem with DBCrossView

edited October 2009 in FastReport 4.0
Hi,

I'm having some trouble with the TfrxDBCrossView component..

I'm dynamically creating report and cross view from code.
I add every field i need BUT i can't see the result grid in the report preview (Report.ShowReport;).
If i go in editing mode (Report.DesignReport;) changing the cross view, then i can see the preview.

Anyone can help me? I think i should call a method but i can't find it.

Greetings, Viper

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 8:55PM
    need to see the code.
    post it in the binaries news group.
  • edited 8:55PM
    Report create..
    Report := TfrxReport.Create(Self);
      Report.CreateUniqueName;
      Report.PreviewOptions.Buttons:=[pbPrint,pbExport,pbZoom,pbFind
          ,pbOutline,pbPageSetup,pbTools,pbNavigator,pbExportQuick];
      DataSet := TfrxDBDataset.Create(self);
      DataSet.Name := 'ReportDataset1';
      DataSet.DataSource := DatasourceX;
      Report.DataSets.Add(Dataset);
      DataPage := TfrxDataPage.Create(Report);
      Page := TfrxReportPage.Create(Report);
      Page.CreateUniqueName;
      Page.SetDefaults;
      Cross := TfrxDBCrossView.Create(Page);
      Cross.DataSet := DataSet;
      with Cross do
        begin
          CreateUniqueName;
          Top := 45;
          Left := 0;
          Width := 100;
          Height := 100;
          ShowTitle := False;
          ShowCorner := False;
          ShowColumnHeader := True;
          AutoSize := True;
          Border := True;
          DownThenAcross := False;
          RepeatHeaders := True;
          PlainCells := True;
          JoinEqualCells := False;
          ShowRowHeader := True;
          ShowColumnTotal := True;
          ShowRowTotal := True;
        end;
    

    Adding fields..
    cross.RowFields.Add(fieldname);
    cross.RowLevels := cross.RowFields.Count;
    
    .
    .
    .
    
    cross.CellFields.Add(fieldname);
    cross.CellLevels := cross.CellFields.Count;
    
    .
    .
    .
    
    cross.ColumnFields.Add(fieldname);
    cross.ColumnLevels := cross.ColumnFields.Count;
    
  • gordkgordk St.Catherines On. Canada.
    edited 8:55PM
    2 things i see
    1 you should be adding your fields before the end; of the cross creation
    2 your levels need to be set correctly.
    here is a sample using the demodata crosstab.db

    procedure TForm1.Button5Click(Sender: TObject);
    var
    report:tfrxreport;
    dataset:tfrxdbdataset;
    datapage:tfrxdatapage;
    page:tfrxreportpage;
    cross:tfrxdbcrossview;
    begin
    Report := TfrxReport.Create(Self);
    Report.CreateUniqueName;
    Report.PreviewOptions.Buttons:=[pbPrint,pbExport,pbZoom,pbFind,pbOutline,pbPageSetup,pbTools,pbNavigator,pbExportQuick];
    DataSet := TfrxDBDataset.Create(self);
    DataSet.Name := 'ReportDataset1';
    DataSet.DataSource := reportdata.CrossSource;// linked to crosstab demo data in data module
    Report.DataSets.Add(Dataset);
    DataPage := TfrxDataPage.Create(Report);
    Page := TfrxReportPage.Create(Report);
    Page.CreateUniqueName;
    Page.SetDefaults;
    Cross := TfrxDBCrossView.Create(Page);
    Cross.DataSet := DataSet;
    with Cross do
    begin
    CreateUniqueName;
    Top := 45;
    Left := 0;
    Width := 100;
    Height := 100;
    ShowTitle := False;
    ShowCorner := False;
    ShowColumnHeader := True;
    AutoSize := True;
    Border := True;
    DownThenAcross := False;
    RepeatHeaders := True;
    PlainCells := True;
    JoinEqualCells := False;
    ShowRowHeader := True;
    ShowColumnTotal := True;
    ShowRowTotal := True;
    rowfields.Add('Name');
    rowlevels:=1;
    cellfields.Add('Salary');
    cellLevels := 1;
    columnfields.Add('Year');
    columnlevels:=1;
    end;
    report.showReport;
    end;
  • edited 8:55PM
    Thank you very much! :lol:" border="0" alt="laugh.gif" />" alt=">" />
  • edited October 2009
    When i add fields dynamically, DBCrossView doesn't appear in the report so i call this function

    ...
    Cross: TfrxDBCrossView;
    DataSet: TfrxDBDataset;
    ...
    procedure TReportMan.RefreshCross;
    begin
    
        Cross.DataSet := TfrxCustomDBDataSet(Dataset);
        Cross.RowLevels := Cross.RowFields.Count;
        Cross.ColumnLevels := Cross.ColumnFields.Count;
        Cross.CellLevels := Cross.CellFields.Count;
    end;
    

    and all works as i wish >

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.