EhLib.Com
https://forum.ehlib.com/en/

Manual Grouping in DBGridEh
https://forum.ehlib.com/en/viewtopic.php?f=5&t=1017
Page 1 of 1

Author:  OlafESH [ 27 Jan 2020, 10:22 ]
Post subject:  Manual Grouping in DBGridEh

Hello friends out there,

I'm in need to manually setup grouping in DBGridEh. This is needed, as we usually modify the SQL statement accessing the SQL-Server. However, this kills the complete grouping (underlying MemTableEh is closed thus losing all the Fields from DBGridEh.DataGrouping.GroupLevels).

So we need to restore this manually. But: There is no "ColumnName" in any of the properties accessible by code - this property only exists in Designer. As usual the example is ultra simple showing only the extreme basics, Docs do not tell us anything more.

So: How do we restore the grouping in code ?

Thanks for help !

Author:  EhLibSupport [ 27 Jan 2020, 14:02 ]
Post subject:  Re: Manual Grouping in DBGridEh

Hello

You can use TGridDataGroupLevelEh.Column to assign column for a GroupLevel.

Here is an code example:

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  grLevel: TGridDataGroupLevelEh;
begin
  DBGridEh1.DataGrouping.Active := False;
  grLevel := DBGridEh1.DataGrouping.GroupLevels.Add;
  grLevel.Column := DBGridEh1.FieldColumns['Capital'];
  DBGridEh1.DataGrouping.Active := True;
end;


TDBGridEh.FieldColumns finds and returns column by column.FieldName property.

Author:  OlafESH [ 28 Jan 2020, 10:00 ]
Post subject:  Re: Manual Grouping in DBGridEh

This worked great, thanks a lot !

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/