This is because the value is not stored in the grid when connecting it via a database adapter. You need to access the value directly. Please check the following sample
procedure TForm1.TMSFNCGrid1GetCellLayout(Sender: TObject; ACol, ARow: Integer;
ALayout: TTMSFNCGridCellLayout; ACellState: TTMSFNCGridCellState);
var
activeRecord, c, i: Integer;
monChamp: TField;
maGrille: TTMSFNCGrid;
monAdaptateurGrille: TTMSFNCGridDatabaseAdapter;
o: Integer;
begin
maGrille := TTMSFNCGrid(Sender);
if (ARow <= maGrille.FixedRows - 1) then
Exit;
c := ACol - maGrille.FixedColumns;
if (c >= 0) and (c <= maGrille.Columns.Count - 1) then
begin
monAdaptateurGrille := TTMSFNCGridDatabaseAdapter
(TMSFNCGridDatabaseAdapter1);
if monAdaptateurGrille.CheckDataSet then
begin
activeRecord := monAdaptateurGrille.DataLink.activeRecord;
try
o := monAdaptateurGrille.DataLink.ActiveRecord;
monAdaptateurGrille.SetActiveRecord(ARow);
if (monAdaptateurGrille.DataLink.ActiveRecord < 0) or ((monAdaptateurGrille.DataLink.ActiveRecord >= monAdaptateurGrille.DataLink.BufferCount) and
not ((monAdaptateurGrille.DataLink.ActiveRecord = monAdaptateurGrille.DataLink.BufferCount) and (monAdaptateurGrille.DataSetType = adsNonSequenced))) then
begin
monAdaptateurGrille.DataLink.ActiveRecord := o;
Exit;
end;
monChamp := monAdaptateurGrille.FieldAtColumn[3];
if Assigned(monChamp) then
begin
i := 0;
if TryStrToInt(monChamp.AsString, i) then
begin
if i > 50000 then // ou autre chose
begin
ALayout.Fill.Color := gcRed;
end;
end;
end;
finally
monAdaptateurGrille.DataLink.activeRecord := activeRecord;
end;
end;
end;
end;
Oke this works, i would think dat is was al little easier.
What if i would like to clear a complete cell depending on a certain value of a field.
The old code i the FMX Grid was
grlBegroting.Cells[4,ARow] :='';
You should use the dataset directly to clear a field value instead, which will reflect in the grid. There is currently no interface available to programmatically clear a value in the grid. We are discussing this here and might in the future, redesign the database link to properly integrate programmatic and visual actions in the grid