Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 28 Mar 2024, 10:42

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 01 Apr 2023, 22:11 
Offline

Joined: 14 Jul 2022, 08:46
Posts: 22
Hi

How to set the data group GroupLevels for one field (company) and for two fields (company & ShipVIA) by coding

Best Regards


Attachments:
ehlib.jpg
ehlib.jpg [ 148.03 KiB | Viewed 1143 times ]
Top
 Profile  
 
PostPosted: 03 Apr 2023, 11:59 
Offline

Joined: 14 Jul 2022, 08:46
Posts: 22
Solution found in :
viewtopic.php?f=5&t=633#p1402


Top
 Profile  
 
PostPosted: 05 Apr 2023, 15:29 
Offline

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

Here are some examples of working with groups at runtime.
In the last example grouping by two fields.

Code:
//Activate DataGrouping
procedure TForm1.Button1Click(Sender: TObject);
begin
  DBGridEh1.DataGrouping.Active := True;
  DBGridEh1.DataGrouping.GroupPanelVisible := True;
end;

//Add GroupLevel for 'Continent' Field
procedure TForm1.Button2Click(Sender: TObject);
var
  gl: TGridDataGroupLevelEh;
begin
  gl := DBGridEh1.DataGrouping.GroupLevels.Add();
  gl.Column := DBGridEh1.FieldColumns['Continent'];
  //Expand all nodes of the First Level
  DBGridEh1.DataGrouping.GroupLevels[0].ExpandNodes;
end;

//Delete first GroupLevel
procedure TForm1.Button3Click(Sender: TObject);
begin
  if (DBGridEh1.DataGrouping.GroupLevels.Count > 0) then
    DBGridEh1.DataGrouping.GroupLevels.Delete(0);
end;

//Replace Field for the first GroupLevel
procedure TForm1.Button4Click(Sender: TObject);
begin
  if DBGridEh1.DataGrouping.GroupLevels.Count = 0 then Exit;

  if (TColumnEh(DBGridEh1.DataGrouping.GroupLevels[0].Column).FieldName = 'Continent')
    then DBGridEh1.DataGrouping.GroupLevels[0].Column := DBGridEh1.FieldColumns['Capital']
    else DBGridEh1.DataGrouping.GroupLevels[0].Column := DBGridEh1.FieldColumns['Continent'];

  //Expand all nodes of the First Level
  DBGridEh1.DataGrouping.GroupLevels[0].ExpandNodes;
end;

//Add several GroupLevels
procedure TForm1.Button5Click(Sender: TObject);
begin
  DBGridEh1.DataGrouping.GroupLevels.BeginUpdate;
  DBGridEh1.DataGrouping.GroupLevels.Clear;

  DBGridEh1.DataGrouping.GroupLevels.Add().Column := DBGridEh1.FieldColumns['Continent'];
  DBGridEh1.DataGrouping.GroupLevels.Add().Column := DBGridEh1.FieldColumns['Capital'];

  DBGridEh1.DataGrouping.GroupLevels.EndUpdate;

  //Expand all nodes of the First Level
  DBGridEh1.DataGrouping.GroupLevels[0].ExpandNodes;
end;

_________________
Best regards
EhLib Support Team


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 62 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