You may use DevExpress Printing System wich will print exaclty your grid.
You can also use try the following code wich is intended
to navigate the grid from first to last record and synchronise
the TcxGgrid's dataset. It is also expanding groups automatically
to get that data in it.
ds_liste is a TfrDBDataset.
This applies only if the TcxGridDBTableView.DataController.DataModeController.GridMode is set to False.
(I am actually looking for something better because this code
does not support the double pass report).
procedure TDM_PrintListe.ds_listeFirst(Sender: TObject);
begin
if ViewData <> nil then
with ViewData do
begin
if RecordCount >= 1 then
begin
if Records[CurrentRecord].Expandable then
begin
Records[CurrentRecord].Expand(False);
GotoNextRecord (ViewData);
end
else
Records[CurrentRecord].Focused := True;
end
else CurrentRecord :=-1;
end;
end;
procedure TDM_PrintListe.GoToNextRecord (ViewData : TcxGridViewData);
begin
with ViewData do
if CurrentRecord < RecordCount-1 then
begin
Inc (CurrentRecord);
if Records[CurrentRecord].Expandable then
begin
Records[CurrentRecord].Expand(False);
GotoNextRecord (ViewData);
end
else
Records[CurrentRecord].Focused := True;
end
else Inc (CurrentRecord);
end;
procedure TDM_PrintListe.ds_listeNext(Sender: TObject);
begin
if ViewData <> nil then
with ViewData do
begin
if CurrentRecord < RecordCount-1 then
begin
gotoNextRecord (ViewData);
end
else Inc (CurrentRecord);
end;
end;
procedure TDM_PrintListe.ds_listeCheckEOF(Sender: TObject;
var Eof: Boolean);
begin
if ViewData <> nil then
with ViewData do
begin
eof := CurrentRecord >= RecordCount;
end;
end;
Thanks for the sample code. It compiles but how do I get the fields from the grid onto the report? I only know how to do this by selecting the fields from a tdataset. In this case it is from a tcxGrid via a tfrdbdataset and these don't show up while designing the report.
Comments
You can also use try the following code wich is intended
to navigate the grid from first to last record and synchronise
the TcxGgrid's dataset. It is also expanding groups automatically
to get that data in it.
ds_liste is a TfrDBDataset.
This applies only if the TcxGridDBTableView.DataController.DataModeController.GridMode is set to False.
(I am actually looking for something better because this code
does not support the double pass report).
....
private
{ D?©clarations priv?©es }
CurrentRecord : Longint;
ViewData : TcxGridViewData;
....
procedure TDM_PrintListe.ds_listeFirst(Sender: TObject);
begin
if ViewData <> nil then
with ViewData do
begin
if RecordCount >= 1 then
begin
if Records[CurrentRecord].Expandable then
begin
Records[CurrentRecord].Expand(False);
GotoNextRecord (ViewData);
end
else
Records[CurrentRecord].Focused := True;
end
else CurrentRecord :=-1;
end;
end;
procedure TDM_PrintListe.GoToNextRecord (ViewData : TcxGridViewData);
begin
with ViewData do
if CurrentRecord < RecordCount-1 then
begin
Inc (CurrentRecord);
if Records[CurrentRecord].Expandable then
begin
Records[CurrentRecord].Expand(False);
GotoNextRecord (ViewData);
end
else
Records[CurrentRecord].Focused := True;
end
else Inc (CurrentRecord);
end;
procedure TDM_PrintListe.ds_listeNext(Sender: TObject);
begin
if ViewData <> nil then
with ViewData do
begin
if CurrentRecord < RecordCount-1 then
begin
gotoNextRecord (ViewData);
end
else Inc (CurrentRecord);
end;
end;
procedure TDM_PrintListe.ds_listeCheckEOF(Sender: TObject;
var Eof: Boolean);
begin
if ViewData <> nil then
with ViewData do
begin
eof := CurrentRecord >= RecordCount;
end;
end;
Thanks.