0

Why all datagrid like as follows are failing in iOS Simulator without any error message. It just run and gone after installation. I could not find any documentation related to this failures.

  1. TGrid
  2. TMSFMXGrid
  3. TeeGrid

But its running perfectly fine in windows. Not sure with Android. Haven't tried yet. My only concern now is with iOS. All the type of grids not working.

I did some basic RME TGrid sample in multi-device application for reference:

PROCEDURE

unit Unit9;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Rtti,
  FMX.Grid.Style, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error,
  FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool,
  FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.SQLite, FireDAC.Phys.SQLiteDef,
  FireDAC.Stan.ExprFuncs, FireDAC.FMXUI.Wait, FireDAC.Stan.Param, FireDAC.DatS,
  FireDAC.DApt.Intf, FireDAC.DApt, Data.Bind.EngExt, Fmx.Bind.DBEngExt,
  Fmx.Bind.Grid, System.Bindings.Outputs, Fmx.Bind.Editors,
  Data.Bind.Components, Data.Bind.Grid, Data.Bind.DBScope, Data.DB,
  FireDAC.Comp.DataSet, FireDAC.Comp.Client, FMX.Controls.Presentation,
  FMX.ScrollBox, FMX.Grid;

type
  TForm9 = class(TForm)
    grd1: TGrid;
    conSqlite_demoConnection: TFDConnection;
    qryCustomersTable: TFDQuery;
    bdr1: TBindSourceDB;
    bdl1: TBindingsList;
    lnkgrdtdtsrcBindSourceDB: TLinkGridToDataSource;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form9: TForm9;

implementation

{$R *.fmx}

end.

FMX FILE

object Form9: TForm9
  Left = 0
  Top = 0
  Caption = 'Form9'
  ClientHeight = 480
  ClientWidth = 289
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [Desktop]
  DesignerMasterStyle = 0
  object grd1: TGrid
    Align = Client
    CanFocus = True
    ClipChildren = True
    Size.Width = 289.000000000000000000
    Size.Height = 480.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 0
    RowCount = 91
    Viewport.Width = 269.000000000000000000
    Viewport.Height = 439.000000000000000000
  end
  object conSqlite_demoConnection: TFDConnection
    Params.Strings = (
      'ConnectionDef=SQLite_Demo')
    Connected = True
    LoginPrompt = False
    Left = 118
    Top = 206
  end
  object qryCustomersTable: TFDQuery
    Active = True
    Connection = conSqlite_demoConnection
    SQL.Strings = (
      'SELECT * FROM Customers')
    Left = 118
    Top = 254
  end
  object bdr1: TBindSourceDB
    DataSet = qryCustomersTable
    ScopeMappings = <>
    Left = 128
    Top = 224
  end
  object bdl1: TBindingsList
    Methods = <>
    OutputConverters = <>
    Left = 20
    Top = 5
    object lnkgrdtdtsrcBindSourceDB: TLinkGridToDataSource
      Category = 'Quick Bindings'
      DataSource = bdr1
      GridControl = grd1
      Columns = <>
    end
  end
end

UPDATE 1 I my case above I used the LiveBindings but this error is true also if used through Datasource all of the 3 types of grid components.

UPDATE 2 If I set to false both fdconnection and fdquery, it works. And, if I set to true only the fdconnection, again its not working. I suspect the issue emanates from the connection itself and I also want to believe its coming from the dataset also.

UPDATE 3 Removed all the connections and manually code that instead but still no luck. I tried to figure out the error but it makes no sense to me. Connection and ConnectionName can be empty if I do it at design time.

Here's the error message:

Connection Error Messager

Here's my new manual code connection:

unit Unit9;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Rtti,
  FMX.Grid.Style, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error,
  FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool,
  FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.SQLite, FireDAC.Phys.SQLiteDef,
  FireDAC.Stan.ExprFuncs, FireDAC.FMXUI.Wait, FireDAC.Stan.Param, FireDAC.DatS,
  FireDAC.DApt.Intf, FireDAC.DApt, Data.DB, FireDAC.Comp.DataSet,
  FireDAC.Comp.Client, FMX.StdCtrls, FMX.Controls.Presentation, FMX.ScrollBox,
  FMX.Grid, FMXTee.Control, FMXTee.Grid, FireDAC.Comp.UI, FireDAC.Phys.MySQLDef,
  FireDAC.Phys.MySQL;

type
  TForm9 = class(TForm)
    btn1: TButton;
    tgd1: TTeeGrid;
    dvr1: TFDPhysMySQLDriverLink;
    procedure btn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form9: TForm9;

implementation

{$R *.fmx}

procedure TForm9.btn1Click(Sender: TObject);
var
  conn : TFDConnection;
  qry : TFDQuery;
  ds: TDataSource;
begin
  conn := TFDConnection.Create(nil);
  try
    //- Connection parameters
    conn.Params.DriverID := 'MySQL';
    conn.Params.Add('Server=127.0.0.1');
    conn.Params.Database := 'mydb';
    conn.Params.UserName := 'admin';
    conn.Params.Password := '******';
    conn.LoginPrompt := False;

    //- Connect to the database..
    conn.Connected := True;
    if conn.Connected then begin
//      ShowMessage('Connection successful.');
      qry := TFDQuery.Create(conn);
      try
        qry.Active := False;
        qry.SQL.Clear;
        qry.Open('SELECT * FROM city;');
        if qry.Active then
        begin
          if qry.RecordCount > 0 then
          begin
            ds := TDataSource.Create(qry);
            ds.DataSet := qry;
            tgd1.DataSource := ds;
          end;
        end;
      finally
        qry.Free;
      end;
    end else begin
      ShowMessage('Connection Failed.');
    end;
  finally
    conn.Free;
  end;

end;

end.

My new FMX File:

object Form9: TForm9
  Left = 0
  Top = 0
  Caption = 'Form9'
  ClientHeight = 594
  ClientWidth = 338
  FormFactor.Width = 320
  FormFactor.Height = 480
  FormFactor.Devices = [Desktop]
  DesignerMasterStyle = 0
  object btn1: TButton
    Align = Bottom
    Position.Y = 560.000000000000000000
    Size.Width = 338.000000000000000000
    Size.Height = 34.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 0
    Text = 'Connect'
    OnClick = btn1Click
  end
  object tgd1: TTeeGrid
    Columns = <>
    Align = Client
    Size.Width = 338.000000000000000000
    Size.Height = 560.000000000000000000
    Size.PlatformDefault = False
    TabOrder = 1
    _Headers = (
      1
      'TColumnHeaderBand'
      <
        item
        end>)
  end
  object dvr1: TFDPhysMySQLDriverLink
    Left = 152
    Top = 200
  end
end
RickyBelmont
  • 619
  • 4
  • 11
  • Temporarily, forget the grids. Disconnect them from the qryCustomersTable. Set the FDConnection1's Connected property to False and close qryCustomersTable.in the IDE, then add some code to manually set FDConnection1 to true at runtime and give a visual indication whether setting it to true succeeds. What is the result? If it succeeds, do likewise with qryCustomersTable. Only if both succeed, connect the grid(s) to qryCustomersTable. Anyway, get out of the habit of setting dbconnections and datasets active in the IDE. – MartynA Jul 05 '20 at 18:59
  • @MartynA Sorry I still haven't get back to you. I am still working on manual connection to grid showing. Some glitches I am encountering. I will get back to you as soon as I can. – RickyBelmont Jul 06 '20 at 03:13
  • @MartynA I give up! Could not find where the error is coming from. I have updated my question with new procedure of manual connection and new fmx file for this — UPDATE 3. I will appreciate if you could have a quick look if there is something wrong with my connection codes. Thank you! – RickyBelmont Jul 06 '20 at 07:07

0 Answers0