TTMSFMXGrid - no cell value ?

I have a handler assigned to Grid.OnCellEditDone(). The cell has a TSpinBox as the editor.

When changing the spinbox value and pressing Enter or Tab to exit editing, the OnCellEditDone() fires and TSpinBox(CellEditor).Value is correctly available.
When changing the spinbox value and (left)clicking another cell, the OnCellEditDone() fires but the TSpinBox(CellEditor).Value is set to zero.
Any clue on what is happening here?

Hi, 


We have investigated this here but are not able to reproduce this. When clicking another cell, or pressing Enter / Tab, the OnCellEditDone behaves correctly and the SpinBox editor contains the correct value. Please provide a sample or additional instructions on how to reproduce this issue.

Kind Regards, 
Pieter

Pieter,

Below the code to reproduce. The screengrab shows the result.
Start program, enter value in col 1, exit by clicking in col 2 (row independent).

unit Unit1;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.TMSBaseControl, FMX.TMSGridCell, FMX.TMSGridOptions, FMX.TMSGridData,
  FMX.TMSCustomGrid, FMX.TMSGrid;

type
  TForm1 = class(TForm)
    Grid: TTMSFMXGrid;
    procedure GridCellEditDone(Sender: TObject; ACol, ARow: Integer;
      CellEditor: TFmxObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

uses
  FMX.SpinBox;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Grid.Cells[1, 0] := 'X';
  Grid.Cells[2, 0] := 'X * 13';
end;

procedure TForm1.GridCellEditDone(Sender: TObject; ACol, ARow: Integer; CellEditor: TFmxObject);
var
  t1, t2: single;

begin
  case aCol of
    0 :;
    1 : begin
          t1 := TSpinBox(CellEditor).Value;
          t2 := t1 * 13;
          Grid.Cells[2, aRow] := t2.ToString;
        end;
    2 :;
  end;
end;

end.

Hi, 


We are not able to reproduce this here in RAD Studio 10 Seattle. Which version are you using?
As an alternative, you could use the OnCellEditSetData event:

procedure TForm19.TMSFMXGrid1CellEditSetData(Sender: TObject; ACol,
  ARow: Integer; CellEditor: TFmxObject; var CellString: string);
var
  t1, t2: single;

begin
  case aCol of
    0 :;
    1 : begin
          t1 := TSpinBox(CellEditor).Value;
          t2 := t1 * 13;
          TMSFMXGrid1.Cells[2, aRow] := t2.ToString;
        end;
    2 :;
  end;
end;

Kind Regards, 
Pieter


Running Seattle 10 and FMX Pack 3.2.3.1. Will test with latest (3.2.4.1) later.



Just installed 3.2.4.1 on Seattle 10. 

Problem persists. I have a short video to demo the issue here.
Up to 00:22 sec I enter data in col1 and exit the cell by clicking col2. From 00:22 I enter data in col1 and exit with <enter>. You see the effects.

Hi, 


We have investigated this here and this seems to be an issue when the TSpinBox is closing, after changing the value with the keyboard. Changing the value with the left/right buttons will increment the value directly. The value is updated upon changing the focus, but in the grid the value is updated after the OnCellEditDone event is triggered, to make sure the editor is still available in this event. We will investigate a possible workaround for this issue, but please note that the behavior of the value only updating after changes with the keyboard in a TSpinBox control is, in our opinion, not the correct sequence and thus an issue in TSpinBox.

An alternative solution is to convert the text value (which is correctly updated in both keyboard changes and left/right button clicks):

procedure TForm19.TMSFMXGrid1CellEditDone(Sender: TObject; ACol, ARow: Integer;
  CellEditor: TFmxObject);
var
  t1, t2: Single;
begin
  case aCol of
    0 :;
    1 : begin
          if TryStrToFloat(TSpinBox(CellEditor).Text, t1) then
          begin
            t2 := t1 * 13;
            TMSFMXGrid1.Cells[2, aRow] := t2.ToString;
          end;
        end;
    2 :;
  end;
end; 

Kind Regards, 
Pieter

Pieter Scheldeman2015-12-31 14:14:33

Thanx Pieter. This does the job as a workaround.