Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 27 Apr 2024, 10:21

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 26 Mar 2024, 08:22 
Offline

Joined: 14 Mar 2024, 14:13
Posts: 5
Hello,

I have code to create data grouping and footer sum as below:

Code:
DBGPiutang.DataGrouping.Active := True;
   gl := DBGPiutang.DataGrouping.GroupLevels.Add();
   gl.Column := DBGPiutang.FieldColumns['Divisi'];
   DBGPiutang.DataGrouping.GroupLevels[0].ExpandNodes;

   Footer := DBGPiutang.DataGrouping.Footers.Add;
   Footer.Visible := True;
   Footer.ParentColor := True;
   Footer.ParentFont := True;
   Footer.ShowFunctionName := True;

   ColumnItem := TGridDataGroupFooterColumnItemEh(Footer.ColumnItems.Add);
   ColumnItem.FieldName := 'SisaFaktur';
   ColumnItem.ValueType := gfvSumEh;


When executing it an error appears :
'[dcc32 Error] UCustomer.pas(397): E2064 Left side cannot be assigned to'

on the line :
ColumnItem.FieldName := 'SisaFaktur';

How to solve it so that this error doesn't appear ?

Thanks
Donoharjo


Top
 Profile  
 
PostPosted: 26 Mar 2024, 10:07 
Offline

Joined: 08 May 2014, 18:06
Posts: 663
Hello

When you add a new row to the DBGridEh1.DataGrouping.Footers collection
The grid automatically creates cell elements in the footer row.
You need to find the desired element by field name and assign an aggregation function.

Here is a code example:

Code:
procedure TForm1.Button2Click(Sender: TObject);
var
  FooterRow: TGridDataGroupFooterEh;
  Column: TColumnEh;
  FooterItemIndex: Integer;
  FooterItem: TGridDataGroupFooterColumnItemEh;
begin
  //Add footer row
  FooterRow := DBGridEh1.DataGrouping.Footers.Add;
  FooterRow.Visible := True;

  //Assign Sum aggregate function for 'Area' column
  Column := DBGridEh1.FieldColumns['Area'];
  FooterItemIndex := FooterRow.ColumnItems.ItemIndexByColumn(Column);
  FooterItem := FooterRow.ColumnItems[FooterItemIndex];
  FooterItem.ValueType := TGroupFooterValueTypeEh.gfvSumEh;
end;

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
PostPosted: 03 Apr 2024, 05:49 
Offline

Joined: 14 Mar 2024, 14:13
Posts: 5
EhLibSupport wrote:
Hello

When you add a new row to the DBGridEh1.DataGrouping.Footers collection
The grid automatically creates cell elements in the footer row.
You need to find the desired element by field name and assign an aggregation function.

Here is a code example:

Code:
procedure TForm1.Button2Click(Sender: TObject);
var
  FooterRow: TGridDataGroupFooterEh;
  Column: TColumnEh;
  FooterItemIndex: Integer;
  FooterItem: TGridDataGroupFooterColumnItemEh;
begin
  //Add footer row
  FooterRow := DBGridEh1.DataGrouping.Footers.Add;
  FooterRow.Visible := True;

  //Assign Sum aggregate function for 'Area' column
  Column := DBGridEh1.FieldColumns['Area'];
  FooterItemIndex := FooterRow.ColumnItems.ItemIndexByColumn(Column);
  FooterItem := FooterRow.ColumnItems[FooterItemIndex];
  FooterItem.ValueType := TGroupFooterValueTypeEh.gfvSumEh;
end;




I have tried with this code:
Code:
// Set footer DBGPiutang
   DBGPiutang.FooterRowCount := 1;
   DBGPiutang.SumList.Active := True;
   DBGPiutang.Columns.Items[3].Footer.ValueType := fvtStaticText;
   DBGPiutang.Columns.Items[3].Footer.Value := 'Total Faktur : ' + IntToStr(DataModule1.qryPiutang.RecordCount);
   DBGPiutang.Columns.Items[3].Footer.Alignment := taCenter;
   DBGPiutang.FooterParams.FillStyle := cfstThemedEh;
   DBGPiutang.FooterFont.Style := [fsBold];

   DBGPiutang.Columns.Items[6].Footer.ValueType := fvtStaticText;
   DBGPiutang.Columns.Items[6].Footer.Value := 'Total Piutang  :';
   DBGPiutang.Columns.Items[6].Footer.Alignment := taCenter;
   DBGPiutang.Columns.Items[7].Footer.ValueType := fvtSum;
   DBGPiutang.Columns.Items[7].Footer.DisplayFormat := '###,##0';

   DBGPiutang.VertScrollBar.Visible := True;

   if DataModule1.qryPiutang.RecordCount * 20 <= DBGPiutang.ClientHeight then
   begin
   DBGPiutang.VertScrollBar.Visible := False;
   end;

   DBGPiutang.DataGrouping.Active := True;
   gl := DBGPiutang.DataGrouping.GroupLevels.Add();
   gl.Column := DBGPiutang.FieldColumns['Divisi'];
   DBGPiutang.DataGrouping.GroupLevels[0].ExpandNodes;

   //Add footer row
   FooterRow := DBGPiutang.DataGrouping.Footers.Add;
   FooterRow.Visible := True;

   //Assign Sum aggregate function for 'SisaFaktur' column
   Column := DBGPiutang.FieldColumns['SisaFaktur'];
   FooterItemIndex := FooterRow.ColumnItems.ItemIndexByColumn(Column);
   FooterItem := FooterRow.ColumnItems[FooterItemIndex];
   FooterItem.ValueType := TGroupFooterValueTypeEh.gfvSumEh;
   if FooterItemIndex >= 0 then
   begin
      FooterItem := FooterRow.ColumnItems[FooterItemIndex];
      FooterItem.ValueType := TGroupFooterValueTypeEh.gfvSumEh;
   end;


and the result is:
Image

The question is, why does the footer sum appear twice ?

Thanks


Top
 Profile  
 
PostPosted: 03 Apr 2024, 22:23 
Offline

Joined: 08 May 2014, 18:06
Posts: 663
You add two footers.
The first is a general footer for the grid.

Code:
// Set footer DBGPiutang
   DBGPiutang.FooterRowCount := 1;
   DBGPiutang.SumList.Active := True;
   DBGPiutang.Columns.Items[3].Footer.ValueType := fvtStaticText;
   DBGPiutang.Columns.Items[3].Footer.Value := 'Total Faktur : ' + IntToStr(DataModule1.qryPiutang.RecordCount);
   DBGPiutang.Columns.Items[3].Footer.Alignment := taCenter;
   DBGPiutang.FooterParams.FillStyle := cfstThemedEh;
   DBGPiutang.FooterFont.Style := [fsBold];

   DBGPiutang.Columns.Items[6].Footer.ValueType := fvtStaticText;
   DBGPiutang.Columns.Items[6].Footer.Value := 'Total Piutang  :';
   DBGPiutang.Columns.Items[6].Footer.Alignment := taCenter;
   DBGPiutang.Columns.Items[7].Footer.ValueType := fvtSum;
   DBGPiutang.Columns.Items[7].Footer.DisplayFormat := '###,##0';


The second is for grouping data. A grouping footer is created for each group and for the entire grid.

Code:
   //Add footer row
   FooterRow := DBGPiutang.DataGrouping.Footers.Add;
   FooterRow.Visible := True;

   //Assign Sum aggregate function for 'SisaFaktur' column
   Column := DBGPiutang.FieldColumns['SisaFaktur'];
   FooterItemIndex := FooterRow.ColumnItems.ItemIndexByColumn(Column);
   FooterItem := FooterRow.ColumnItems[FooterItemIndex];
   FooterItem.ValueType := TGroupFooterValueTypeEh.gfvSumEh;
   if FooterItemIndex >= 0 then
   begin
      FooterItem := FooterRow.ColumnItems[FooterItemIndex];
      FooterItem.ValueType := TGroupFooterValueTypeEh.gfvSumEh;
   end;


Сhoose one of the footers that you need.

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 43 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group