DisplayText for Header.Text

TeeGrid VCL / FMX for Embarcadero RAD Studio, Delphi, C++ Builder and Lazarus Free Pascal.
Post Reply
REH Outsourcing
Newbie
Newbie
Posts: 25
Joined: Tue Mar 13, 2018 12:00 am

DisplayText for Header.Text

Post by REH Outsourcing » Thu Jun 14, 2018 8:14 am

Delphi version: Seattle
TTeeGrid version: VCL & FMX Registered version-1.05
Multidevice Application (FMX)
Platform: WIN32

Hello,

There is some possibility (or workaround), of changing the text of the header of the column, without modifying TeeGrid1.Columns ['id']. Header.Text, the problem is that if I change, TeeGrid1.Columns ['id']. Header.Text, to eg TeeGrid1.Columns ['id']. Header.Text: = 'Code', I can no longer, reference that column with TeeGrid1.Columns ['id']. Header.Text.

Note that TeeGrid1.Columns ['id']. Header has a DisplayText property, but it is read-only, ideally it would use a property to get the column by its name and another for the text to be displayed to the user.

Regards.

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: DisplayText for Header.Text

Post by Marc » Thu Jun 21, 2018 7:20 am

Hello,

As an update; we're looking at these recent posts to be able to provide an update with a positive solution to the points listed.

Regards,
Marc Meumann
Steema Support

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: DisplayText for Header.Text

Post by Marc » Thu Jul 05, 2018 8:17 am

Hello,

With respect to this feature request.

Columns search here by Header.Text, it should not be assumed to be an id. A new text property would need to be added to TColumn to offer an alternative approach; assignment and management of that 'id' would also be open to different options but could be considered (eg. adding index as a string when created).

If you require to fix code against a specific column, an alternative approach could be to put in a routine that gives a pointer to the column when first accessed, whereupon you can run other commands against the column once the name has changed.

Code: Select all

var myColumn : TColumn;
begin
    ShowMessage(TeeGrid1.Columns['Name'].Header.Text);
    myColumn := TeeGrid1.Columns['Name'];
    TeeGrid1.Columns['Name'].Header.Text := 'My name 2';

    ShowMessage(myColumn.Header.Text);
end;
Regards,
Marc

REH Outsourcing
Newbie
Newbie
Posts: 25
Joined: Tue Mar 13, 2018 12:00 am

Re: DisplayText for Header.Text

Post by REH Outsourcing » Thu Jul 05, 2018 8:43 am

Thanks for your reply Marc,

At the moment and since I am using your TTeeGrid associated with a TDataSet, I prefer to search the column using TColumn.TagObject that I have observed that keeps a pointer to the TField

In case anyone could find it useful, I'll give the example with TDataGrid, which is a TTeeGrid descendant (you could also use a helper):

Code: Select all

function TDataGrid.ColumnByFieldName (FieldName: string): TColumn;
begin

  for result in Self.Columns do
    if result.TagObject is TField then
      if TField (result.TagObject) .FieldName.ToUpper = FieldName.ToUpper then
        exit;

  // If you did not quit before, it is that there is no column with that field associated.
  raise Exception.CreateFmt ('Can not find column with field% s', [FieldName]);


end;
On the other hand, I suggest the following solution, taking into account that the compatibility should be maintained, it would be to add the property Header.DisplayText, by default that property would have the value of Heder.Text, in this way there would be the possibility of modifying the text of the header of the column that is presented to the user, without affecting the search of columns based on Header.Text.


Greetings.

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: DisplayText for Header.Text

Post by Marc » Thu Jul 05, 2018 1:30 pm

Thanks for posting the feedback; that's useful.

Post Reply