Atozed Forums

Full Version: Send data from Delphi to web client
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
FWIW, DataTables is in the soon plans for 17. Smile

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)
Thank you for the answer.
For the time beeing we'll wiat for v17.
17 is still a ways out, but within months we will have usable betas and are already deploying basic apps online today.
(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.
^^ Can you share the screenshot on how to?
PHP Code:
;procedure TIWForm1.IWAppFormRender(SenderTObject);
begin
   Self
.JavaScript.Add'var w_v_l = ["2018/01","2018/02"]' );
end
HTML/JavaScript
PHP Code:
var config_v = {
 
   type'line',
 
   labelsw_v_l  <=== 

IWTemplateProcessorHTML
PHP Code:
procedure TIWForm1.IWTemplateProcessorHTMLUnknownTag(const ANamestring; var VValuestring);
begin
   
//AName in your HTML {%myDataTableData%}
 
  if AName 'myDataTableData' then
      VValue 
:= 'record, record2, record3, etc';
end
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.