How to populate a user-defined column in an FMX TGrid by LiveBindings

1k Views Asked by At

I am trying to create a TCalendarEdit containing column inside a grid component in the following way.

type
  TDatecell = class(TCalendarEdit)
  end;

  TDateColumn = class(TColumn)
  private
    function CreateCellControl: TStyledControl; override;
  public
    constructor Create(AOwner: TComponent); override;
  end;
...
constructor TDateColumn.Create(AOwner: TComponent);
begin
  inherited;
end;

function TDateColumn.CreateCellControl: TStyledControl;
begin
  Result := TDatecell.Create(Self);
end;

It works fine. Then I am stack at populating the column from a FDQuery field of date type. I am capable to establish a Live Binding link and populate the columns of traditional types as well as I can add my DateColumn to the grid. I tried to connect this column to BindSourceDB by

LinkGridToDataSourceBindSourceDB1.Columns.Add;
LinkGridToDataSourceBindSourceDB1.Columns.Items
[LinkGridToDataSourceBindSourceDB1.Columns.Count-1].
MemberName:='date_set_by_user';

but this destroys all the columns in the grid and creates a new one (I suppose of TColumnType). The event OnGetValue of the grid traditionally used to assign values to cells in user declared columns does not fire if there is a LiveBinding link. I think it is possible to to fill the columns manually, but how can I populate this column with Livebindings mechanism?

0

There are 0 best solutions below