Page 1 of 1
DisplayText for Header.Text
Posted: Thu Jun 14, 2018 8:14 am
by 18683216
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.
Re: DisplayText for Header.Text
Posted: Thu Jun 21, 2018 7:20 am
by Marc
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
Re: DisplayText for Header.Text
Posted: Thu Jul 05, 2018 8:17 am
by Marc
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
Re: DisplayText for Header.Text
Posted: Thu Jul 05, 2018 8:43 am
by 18683216
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.
Re: DisplayText for Header.Text
Posted: Thu Jul 05, 2018 1:30 pm
by Marc
Thanks for posting the feedback; that's useful.