Page 1 of 1

Pass a List of objects in .NET Core to nodejs exportPDF

Posted: Mon Nov 06, 2017 7:59 am
by MichalCh
Hello,

I'd like to ask if there is a way to pass in exportPdf/exportHtml a list of objects (might be converted to json by Newtonsoft Json) as datasource instead of a path to saved json file?

Code: Select all

.NET Core
var objects = new List<FancyClass>() {
new FancyClass() { Name = "Test One" },
new FancyClass() { Name = "Test Two" } }

(...)
in the method then:
byte[] result = await _nodeServices.InvokeAsync<byte[]>("./node/exportPdf", reportPath, objects); <- overload with an extra parameter

Code: Select all

exportPdf file: 

module.exports = function (callback, reportPath, listOfObjects) {
var dataSet = new Stimulsoft.System.Data.DataSet("Demo");
dataSet.readJsonFile("Demo.json"); <- here I'd like to do sth like dataSet.readJson(listOfObjects)/dataset.read(listOfObjects)
I'm sure this topic came up previously but I wasn't able to find that in documentation/example projects/forum. Could you be in any help?

Cheers

Re: Pass a List of objects in .NET Core to nodejs exportPDF

Posted: Wed Nov 08, 2017 3:03 pm
by HighAley
Hello, Michal.

Yes, it's possible to pass the JSON object.
The only thing that you should change is the readJsonFile() method. You should change it to the dataSet.readJson(listOfObjects);

Thank you.