Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

using php query to load datasource

Paul Schlichter asked on March 5, 2016

I have set up the pivot in a php page (pivotreport.php)as suggested in the documentation as follows:
<div id=”pivotContainer”>The component will appear within this DIV.</div>
 <script type=”text/javascript” src=”flexmonster/flexmonster.js”></script>
 <script type=”text/javascript”>
   var params = {filename : “pivotreportdata.php”};
   flexmonster.embedPivotComponent(“flexmonster/”, “pivotContainer”,”100%”, “500”, params,true);
I am using a php query to select the data then send a csv file to the browser
$result = $db_con->query     ……etc
Then using a while statement to add the headers then the data to the csv file:
$csv_output .= implode(‘,’, $row);       $csv_output .= “\r\n”;
then output to the browser
header(‘Content-type: text/plain’);
print $csv_output;
I can row the pivotreportdata.php separately and the data outputs properly.
However when I run the pivotreport.php page, the pivot shows but no data is loaded.
Any help would be appreciated

3 answers

Roman Petrusha Roman Petrusha Flexmonster March 6, 2016

Hi Pauls,
Could you please check with DevTools(F12) if you have any error message? Or send me your pivotreportdata.php sample to test with?


Roman Petrusha Roman Petrusha Flexmonster March 7, 2016

Hi Pauls,
Thank you for the code samples.
Please try to specify the “dataSourceType” in params:

 var params = {
   dataSourceType: "csv",
   filename : "../pivotreportdata.php"
 flexmonster.embedPivotComponent("flexmonster/", "pivotContainer","100%", "650", params, true);

Hope this helps.

Tanya Gryshko Tanya Gryshko Flexmonster December 5, 2016

Hello Paul and all Flexmonster users,
Starting from version 2.3, dataSourceType should be defined the following way:

var params = {
    dataSource: {
        dataSourceType: "csv",
        filename : "../pivotreportdata.php"
var pivot = $("#pivotContainer").flexmonster({
    toolbar: true,
    height: "250",
    report: params


Please login or Register to Submit Answer