Send data from Delphi to web client

<< Click to Display Table of Contents >>

Navigation:  Forum >

Send data from Delphi to web client

Forum link

 


 

04-19-2018, 03:41 PM:

 

Hello,

 

We have IW 14.2 along with XE5.

 

Our html contains DataTables plugin.

 

Tu supply data to DataTables we're trying to use a Delphi function but we don't know how to make the function to return this data to the DataTables js function.

 

We cannot find a way to register either a callback real function (not a procedure), or to pass out/var parameter(s) from the procedure.

 

Any help, example, demo will be much appreciated!

 

Thank you

 


 

04-19-2018, 10:02 PM:

 

FWIW, DataTables is in the soon plans for 17.

 

For 14, you can use REST. But its probably easier just to embed your data in the DOM:

 

https://datatables.net/examples/data_sources/dom.html

 

There are several ways to do this, but it could be as simple as using an IWLabel with RawText (not best option, but quick)

 


 

04-20-2018, 10:31 AM:

 

Thank you for the answer.

 

For the time beeing we'll wiat for v17.

 


 

04-20-2018, 12:41 PM:

 

17 is still a ways out, but within months we will have usable betas and are already deploying basic apps online today.

 


 

04-21-2018, 01:31 PM:

 

(04-19-2018, 03:41 PM)radub Wrote: [ -> ]Hello,

 

We have IW 14.2 along with XE5.

 

Our html contains DataTables plugin.

 

Tu supply data to DataTables we're trying to use a Delphi function but we don't know how to make the function to return this data to the DataTables js function.

 

We cannot find a way to register either a callback real function (not a procedure), or to pass out/var parameter(s) from the procedure.

 

Any help, example, demo will be much appreciated!

 

Thank you

 

Hi, You can use an IWTemplateProcessor wich have a Event called OnUnknowTag to full data to use in DataTable.

 

Other way is put a IWLabel and set Properties RawText := True; Full data to iwlabel and use in DataTable.

 

Other way is OnFormRender add a var with data like Self.JavaScript.Add( 'var myData = xyz'); and use myData on DataTable.

 

I don't use DataTable ok. Is ideas to test and adapt to your case.

 


 

04-27-2018, 07:32 AM:

 

^^ Can you share the screenshot on how to?

 


 

04-27-2018, 12:09 PM:

 

PHP Code:

 

;procedure&nbsp;TIWForm1.IWAppFormRender(Sender:&nbsp;TObject);

 

begin

 

&nbsp; &nbsp;Self.JavaScript.Add(&nbsp;'var&nbsp;w_v_l&nbsp;=&nbsp;["2018/01","2018/02"]'&nbsp;);

 

end;&nbsp;

 

 

 

HTML/JavaScript

 

PHP Code:

 

var&nbsp;config_v&nbsp;=&nbsp;{

 

&nbsp; &nbsp; type:&nbsp;'line',

 

&nbsp; &nbsp; labels:&nbsp;w_v_l&nbsp; <===&nbsp;

 

 

 

 

 

IWTemplateProcessorHTML

 

PHP Code:

 

procedure&nbsp;TIWForm1.IWTemplateProcessorHTMLUnknownTag(const&nbsp;AName:&nbsp;string;&nbsp;var&nbsp;VValue:&nbsp;string);

 

begin

 

&nbsp; &nbsp;//AName&nbsp;in&nbsp;your&nbsp;HTML&nbsp;{%myDataTableData%}

 

&nbsp; &nbsp;if&nbsp;AName&nbsp;=&nbsp;'myDataTableData'&nbsp;then

 

&nbsp; &nbsp; &nbsp; VValue&nbsp;:=&nbsp;'record,&nbsp;record2,&nbsp;record3,&nbsp;etc';

 

end;&nbsp;

 

 

 

 

 


 

06-13-2018, 06:09 AM:

 

Thank you for the solutions.

 

Finally I've manage to create a file and pass its path to the DataTables which happily show the data.