Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Javascript et TFDJSONDataSets



Permlink Replies: 2 - Last Post: Nov 26, 2015 11:06 AM Last Post By: AEE AEE
AEE AEE

Posts: 4
Registered: 12/1/08
Javascript et TFDJSONDataSets
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 7, 2015 9:22 AM
Hi i use Delphi 2007 Datasnap server i had create function who has result in TFDJSONDataSets i dont know how to get data from TFDJSONDataSets in javascript thank's
Bonjour J'utilise Delphi 2007 Datasnap server je créer une function qui a comme resultat TFDJSONDataSets. je ne sais pas comment récuperer ce resultat en utilisant javascript sachant que j'arrive à utiliser le resultat quan c'est un simple texte merci
LAURENCE KILLEN

Posts: 41
Registered: 2/20/00
Re: Javascript et TFDJSONDataSets
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2015 8:29 AM   in response to: AEE AEE in response to: AEE AEE
I am not sure if this is still an active question but I will see if I can help.

The best thing for you to do is to upgrade your Delphi to XE7 or later. Delphi added reflection, which I don't think was in datasnap before that.

In order to use it, you should be using FireDac components and memTables.

Server side
function TQtrMin.GETsomeData(const ID: integer; Center: string; optSelected, cntSelected: integer): TFDJSONDataSets;
const

QRY_ALL = 'Select * '+
'FROM [dbo].[map_qtrmin] '+
'where center = ''%s'' '+
'and id = %d ';

begin
case optSelected of
0:
begin
qryData.SQL.Clear;
qryData.SQL.Add(Format(QRY_ALL, [Center, ID]));
end;

end;

Result := TFDJSONDataSets.Create;
TFDJSONDataSetsWriter.ListAdd(Result, sQTRMINUTES, qryQtrMinutes); <<< this is where it is fone.
end;


function GETsomeData(ID: Integer; Center: string; optSelected: Integer; cntSelected: Integer; const ARequestFilter: string = ''): TFDJSONDataSets;

function TQtrMinClient.GETdata(areaID: Integer; Center: string; optSelected: Integer; cntSelected: Integer; const ARequestFilter: string): TFDJSONDataSets;
begin
if FGETdataCommand = nil then
begin
FGETdataCommand := FConnection.CreateCommand;
FGETdataCommand .RequestType := 'GET';
FGETdataCommand .Text := 'TQtrMin.GETdata';
FGETdataCommand .Prepare(TQtrMin_GETdata);
end;
FGETdataCommand .Parameters[0].Value.SetInt32(ID);
FGETdataCommand .Parameters[1].Value.SetWideString(Center);
FGETdataCommand .Parameters[2].Value.SetInt32(optSelected);
FGETdataCommand .Parameters[3].Value.SetInt32(cntSelected);
FGETdataCommand .Execute(ARequestFilter);
if not FGETdataCommand .Parameters[4].Value.IsNull then
begin
FUnMarshal := TDSRestCommand(FGETdataCommand .Parameters[4].ConnectionHandler).GetJSONUnMarshaler;
try
Result := TFDJSONDataSets(FUnMarshal.UnMarshal(FGETQtrMinutesCommand.Parameters[4].Value.GetJSONValue(True)));
if FInstanceOwner then
FGETQtrMinutesCommand.FreeOnExecute(Result);
finally
FreeAndNil(FUnMarshal)
end
end
else
Result := nil;
end;

What makes it so cool is that there is a wizard that does most of this for you.

HTH

AEE AEE

Posts: 4
Registered: 12/1/08
Re: Javascript et TFDJSONDataSets
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 26, 2015 11:06 AM   in response to: LAURENCE KILLEN in response to: LAURENCE KILLEN
I Use Delphi 10 Seatle and my Function is like That

function TServerMethods1.GetDepotSem(Apprt,residence,sem,code, ssap: string; x:integer): TFDJSONDataSets;
begin
// Clear active so that query will reexecute.
if isGood(code, ssap) then
begin
GetDepot.Active := False;
GetDepot.Params[0].Value := residence;
GetDepot.Params[1].Value := code;
GetDepot.Params[2].Value := Apprt;
GetDepot.Params[3].Value := sem;
GetDepot.Params[4].Value := x;

// Create dataset list
Result := TFDJSONDataSets.Create;
// Add departments dataset
TFDJSONDataSetsWriter.ListAdd(Result, 'sDepot', GetDepot);
end;

how can i use this function using javascript

thank's

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02