Creating grid at runtime problem

Hello,

I'm trying to create a TTMSFMXGrid at runtime and add some columns and rows. Unfortunatelly the grid is being placed on screen, but it's completely empty and no OnGetCellData event is being called.

Column width is > 0 and row heights are > 0 either.

OnGetCellData is assigned but my routine I assign is never called.

Here's my routine for adding a column:

procedure TParameterGrid.InitColumns;
var
  Column   : TGroupAttributeTableColumn;
  GridCol  : TTMSFMXGridColumn;
  HasTitle : Boolean;
begin
  // erste Dimension der Datenhaltung setzen
  SetLength(FDisplayData, FColumns.Count);

  Columns.Clear;
  Columns.Capacity := FColumns.Count;
  RowCount         := 0;
  HasTitle         := false;
  UseColumns       := false;

  for Column in FColumns do
  begin
    GridCol            := Columns.Add;
    GridCol.ReadOnly   := true;
    GridCol.ColumnType := TTMSFMXGridColumnType.ctDefault;
    GridCol.ID         := Column.ColumnNo.ToString;

    GridCol.Width := 50;

    // Gibt es eine Überschrift?
    if Column.ColumnTextID >= 0 then
    begin
      if (RowCount = 0) then
      begin
        RowCount  := 1;
        FixedRows := 1;
        HasTitle  := true;
      end;
    end;
  end;

  // wenn mindestens eine Spalte einen Titel hat diese initialisieren
  if HasTitle then
    for Column in FColumns do
    begin
      SetLength(FDisplayData[Column.ColumnNo], 1);

      if Column.ColumnTextID >= 0 then
        SetCell(Column.ColumnNo, 0, 'Spalte ' + Column.ColumnNo.ToString)
        //TFanParameterFormBasicServices.GetTranslatedText(Column.ColumnTextID))
      else
        SetCell(Column.ColumnNo, 0, '');
    end;

  ColumnCount := Columns.Count;
  UnHideColumnsAll;
end;

and here the constructor of my wrapper:

constructor TParameterGrid.Create(Parent  : TFMXObject;
                                  Margins : Single;
                                  Columns : TGroupAttributeTableColumnList);
begin
  inherited Create(parent);

  self.Parent        := Parent;
  ScrollMode         := smPixelScrolling;

  self.Margins.Left  := Margins;
  self.Margins.Right := Margins;
  self.Anchors       := [TAnchorKind.akLeft, TAnchorKind.akRight, TAnchorKind.akTop];

  FColumns           := Columns;

  OnGetCellData      := GetCellData;
  OnResize           := DoResize;

  InitColumns;

  // grid.RowHeights[RowIndex]: single
end;

What am I'm doing wrong? The grid is only being painted as a white rectangle with black border... 

You have sent the same question by direct email and we answered it via direct email.


Hello,

thanks for answering via e-mail. The solution for others to read here is to follow this article:
https://www.tmssoftware.com/site/tmsfmxpack.asp?s=faq&show=652