Can't use with my own AJAX call

Stimulsoft Reports.JS discussion
Post Reply
hugo
Posts: 359
Joined: Fri Mar 08, 2013 10:46 am

Can't use with my own AJAX call

Post by hugo »

Hello,

I already saw Reports.JS working with your PHP to MySQL helper + connection string inject on MRT.

I'm now trying to create a report without MySQL connection string inject on MRT but I don't know what I'm missing.
The report is always empty and without any error.

HTML:

Code: Select all

<!DOCTYPE html>
<html>
<link href="stimulsoft.viewer.office2013.css" rel="stylesheet">
<script src="stimulsoft.reports.js"></script>
<script src="stimulsoft.viewer.js" type="text/javascript"></script>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>

<script type="text/javascript">
	//StiOptions.WebServer.url = "handler.php";

	var options = new Stimulsoft.Viewer.StiViewerOptions();
	options.toolbar.showAboutButton = false;
	options.appearance.showTooltips = false;

	var report = new Stimulsoft.Report.StiReport();
	report.loadFile("Users.mrt");
	report.render();

	var viewer = new Stimulsoft.Viewer.StiViewer(options);

	$.ajax({
		type : 'POST',
		url  : 'myhelper.php',
		dataType: 'json',
		success: function(response)
		{
			var dataSet = new Stimulsoft.System.Data.DataSet("Patient");
			dataSet.readJson(response);

			report.dictionary.databases.clear();
			report.regData(dataSet.dataSetName, "", dataSet);

			viewer.report = report;
		}
	});
	
	
	
</script>

<body>
</body>
</html>
JSON returned from my own MySQL helper (similar to your helper):

Code: Select all

{
	"success": true,
	"notice": null,
	"object": null,
	"columns": ["Id", "User"],
	"rows": [
		["1", "hugo1"],
		["2", "User2"],
		["3", "User3"]
	]
}
I also tryed to use JSON file without sucess:

Code: Select all

{
	"User" : [{
			"Id" : 1,
			"Name" : "User 1"
		}, {
			"Id" : 2,
			"Name" : "User 2"
		}
    ]
}
Users.mrt (just a very simple use case with a band and a field):

Code: Select all

{"ReportGuid":"03c6d42273a5-0942-262d-b7e2d99c5b9e","ReportName":"Report","ReportAlias":"Report","ReportCreated":"/Date(1458689715000+0000)/","ReportChanged":"/Date(1458689715000+0000)/","CalculationMode":"Interpretation","Dictionary":{"DataSources":{"0":{"Ident":"StiMySqlSource","Name":"Patient","Alias":"Patient","Columns":{"0":{"Name":"Name","Index":-1,"NameInSource":"Name","Alias":"Name","Type":"System.String"}},"NameInSource":"Patient","Type":0}}},"Pages":{"0":{"Ident":"StiPage","Name":"Page1","Guid":"d43d198c-7c8c-d32f-ba75-565f4a1e24a7","Interaction":{"Ident":"StiInteraction"},"Border":";;2;;;;;solid:Black","Brush":"solid:","Components":{"0":{"Ident":"StiDataBand","Name":"DataBand1","ClientRectangle":"0,0.4,19.01,1","Interaction":{"Ident":"StiBandInteraction"},"Border":";;;;;;;solid:Black","Brush":"solid:","Components":{"0":{"Ident":"StiText","Name":"Text1","MinSize":"0,0","MaxSize":"0,0","ClientRectangle":"2.8,0,3,0.6","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"Name"},"Border":";;;;;;;solid:Black","Brush":"solid:","TextBrush":"solid:Black"},"1":{"Ident":"StiText","Name":"Text2","MinSize":"0,0","MaxSize":"0,0","ClientRectangle":"5.8,0,8.2,0.6","Interaction":{"Ident":"StiInteraction"},"Text":{"Value":"{Patient.Name}"},"Border":";;;;;;;solid:Black","Brush":"solid:","TextBrush":"solid:Black"}},"DataSourceName":"Patient","DataRelationName":"[Not Assigned]"}},"PageWidth":21.01,"PageHeight":29.69,"Watermark":{"TextBrush":"solid:50,0,0,0"},"Margins":{"Left":1,"Right":1,"Top":1,"Bottom":1}}}}
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Can't use with my own AJAX call

Post by HighAley »

Hello.

Please, try to use next code:

Code: Select all

report.dictionary.dataSources.clear();
report.regData("Patient", "Patient", dataSet);
report.dictionary.synchronize();
Thank you.
hugo
Posts: 359
Joined: Fri Mar 08, 2013 10:46 am

Re: Can't use with my own AJAX call

Post by hugo »

I have now Reports.JS working like I wanted.

Thank you.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Can't use with my own AJAX call

Post by HighAley »

Hello.

We are always glad to help you.

Thank you.
Post Reply