Need a special offer?Find out if your project fits.
+

using php query to load datasource

Answered
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);
 </script>
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

Public
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?

Regards,
 Roman

Public
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.
 
Regards,
Roman

Public
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
});  

Regards,
Tanya

Please login or Register to Submit Answer