I imitate the example from Jose Leon to make a web app and connect it with data from a server. For the json file i set the TWebClientConnection.URI = 'https://jsonplaceholder.typicode.com/photos'.
I Also add a TWebTableControl and a TWEbClientDataSet on the form.
unit UFrmMain;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, Vcl.StdCtrls, WEBLib.StdCtrls, Vcl.Controls,
WEBLib.WebCtrls, WEBLib.REST, WEBLib.Grids, Vcl.Grids, WEBLib.DBCtrls,
WEBLib.DB, WEBLib.CDS, DB;
type
TForm1 = class(TWebForm)
WebTableControl1: TWebTableControl;
WebDataSource1: TWebDataSource;
cds: TWebClientDataSet;
conn: TWebClientConnection;
procedure cdsAfterOpen(DataSet: TDataSet);
private
{ Private declarations }
public
{ Public declarations }
procedure populateTable;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.cdsAfterOpen(DataSet: TDataSet);
begin
populateTable;
end;
procedure TForm1.populateTable;
var
i: integer;
cell: string;
begin
i := 0;
repeat
cell := format(
'
- '+
- %s '+
- %s '+
- %s '+
'
'
'
'
'
',[
cds.FieldByName('title').AsString,
cds.FieldByName('url').AsString,
cds.FieldByName('thumbnailUrl').AsString
]);
WebTableControl1.Cells[0,i] := cell;
Inc(i);
if (i>=4) then Break;
until (cds.Eof);
end;
end.
The UFRMMain.html file:
TitleHow to get the data from the other objects?