We have added the overload LoadFromJSON(AJSON: TJSObject; ADataNode: string) to be able to work with JSON objects directly.
The GetCellXXX methods are protected methods calling event handlers. Their sole purpose is call the possible assigned event handlers.
The ASM code will convert a JSONObject into a delimited string that can then be parsed by a TStringList class.
I have the same issue and I have just too little experience to know how to do this. I can load the JSON from a URL, but the URL now requires a bearer token in the header. Without the bearer token I can load the data fine from the XData server.
So, now with the requirement of a bearer token, I either need the ability to modify the headers for LoadFromJSON or I need the overloaded method you describe here in this post; LoadFromJSON(AJSON: TJSObject; ADataNode: string)
When I try and parse the JSON to a TJSObject and use the method, like this:
procedure(AResponse: string; AReq: TJSXMLHttpRequest)
var
JS: TJSON;
xx: TJSONObject;
begin
JS := TJSON.Create;
try
xx:=TJSONObject(JS.Parse(AResponse));
DogDataGrid.LoadFromJSON(xx,'value');
...
I get a error:
Pas2JS Compiler version 2.1.1 [2021/09/19] for Win32 i386 / TMS WEB Core version v1.9.0.0
[Error] MainUnit.pas(222): Incompatible type arg no. 1: Got "TJSONObject", expected "String"
How do I use LoadFromJSON(AJSON: TJSObject; ADataNode: string) ?
Regards
ViV
First parameter is either TJSObject or string , not TJSONObject.
Use therefore,
uses
js;
var
xx: TJSObject;
begin
xx:=TJSObject(TJSJSON.Parse(AResponse));
DogDataGrid.LoadFromJSON(xx,'value');
end;
Thank you for the reply ...
I see the difference between TJSObject and TJSONObject, I changed it, but it still does not work.
Error:
Pas2JS Compiler version 2.1.1 [2021/09/19] for Win32 i386 / TMS WEB Core version v1.9.0.0
[Error] MainUnit.pas(222): Incompatible type arg no. 1: Got "TJSObject", expected "String"
Error during compilation
Any thoughts on what I am doing wrong?
Regards
ViV
I cannot see why you still get this error. In WEBLib.Grids.pas , there is clearly an overload:
procedure LoadFromJSON(const AURL: string; ADataNode: string = ''); overload;
procedure LoadFromJSON(AJSON: TJSObject; ADataNode: string = ''); overload;
so, the compiler should see the 2nd option.
Can you check that WEBLib.Grids.pas you compile against effectively has this overload in TCustomStringGrid?
I think I found the issue ..
Sorry I did not pick this up in the beginning;
Here is my declaration:
DogDataGrid: TWebResponsiveGrid;
Looking in the WEBLib.Grids, I do not see the the overloaded method :
{$IFNDEF LCLTMSWEB}
[ComponentPlatforms(TMSWebPlatform)]
{$ENDIF}
TWebResponsiveGrid = class(TWebCustomControl)
private
....
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure LoadFromJSON(const AURL: string; ADataNode: string = '');
procedure LoadFromCSV(const AURL: string; Delimiter: char = ';');
....
Is there a way to get the overloaded method into this type of Grid?
Regards
ViV
TWebResponsiveGrid is not having this overload yet. We would need to add it to this class.
Thank you very much. Is this something that will be added or should I find another way around this issue?
Regards
ViV
We have added these overloads and these will be available in the next update.