I use the following way to define and populate a column with TCalendarEdit ancessor cells (here is the interface part). Let me know if I need to expose implementation.
type
TDynamicRecord = record
Field1, Field2, Field3: string;
DateSBU: TDate;
TimeSBU: TTime;
end;
TDateCell = class(TCalendarEdit)
protected
procedure SetData(const Value: TValue); override;
public
constructor Create(AOwner: TComponent); override;
end;
TDateColumn = class(TColumn)
protected
function CreateCellControl: TStyledControl; override;
public
constructor Create(AOwner: TComponent); override;
end;
The code works fine and the column of type TDateColumn
can be added to the grid.
I asked a question and opened a bounty for it looking for a technique to populate the user defined column by LiveBindings
but I have got no answers by the bounty expiry date. That is why now I am trying another way.
I declare a collection DynamicData: TList<TDynamicRecord>;
and populate it from the dataset. This approach is quite clearly explained in the answer of @Mike-Sutton and in his blog. I have managed to do this. The data is displayed properly in the grid and in its newly defined columns.
But now I am stuck with the other problem. I need to update dataset on user activities. I tried the OnSetValue
and OnEditingDone
events of the parent grid (according to the documentation these event are to be used for data updates) but strangely it does not fire.
What will be the proper event or other way suitable for updating the dataset?