0

为什么像下面这样的所有数据网格在 iOS 模拟器中都失败而没有任何错误消息。它只是运行并在安装后消失。我找不到与此故障相关的任何文档。

  1. 网格
  2. TMSFMXGrid
  3. 三通网格

但它在 Windows 中运行得非常好。不确定与Android。还没试过。我现在唯一关心的是iOS。所有类型的网格都不起作用。

我在多设备应用程序中做了一些基本的 RME TGrid 示例以供参考:

程序

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文件

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

更新 1 我在上面的案例中使用了 LiveBindings,但如果通过 Datasource 使用所有 3 种类型的网格组件,则此错误也是正确的。

更新 2 如果我将 fdconnection 和 fdquery 都设置为 false,它可以工作。而且,如果我仅将 fdconnection 设置为 true,则它再次不起作用。我怀疑问题来自连接本身,我也想相信它也来自数据集。

更新 3 删除了所有连接并手动编写代码,但仍然没有运气。我试图找出错误,但这对我来说毫无意义。如果我在设计时这样做,Connection 和 ConnectionName 可以为空。

这是错误消息:

连接错误消息器

这是我的新手动代码连接:

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.

我的新 FMX 文件:

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
4

0 回答 0