I have read the doc about setting the report JSON file to the tool. But in my case, I'm getting a report JSON object from the backend and I need to set it to the tool directly. I don't have JSON file to load report.
Hello, Zain!
Thank you for writing to us.
Flexmonster allows loading the report from the file system or via URL. It is possible to set the report in the following way:
let pivot = new Flexmonster({
container: "#pivot-container",
toolbar: true,
report: "http://localhost:3000/report"
})
Also, you are welcome to check out the following guide on how to restore the report via code: https://www.flexmonster.com/doc/save-and-restore-report/#restore-report
Please let us know if you found this information helpful.
Best Regards,
Maksym
Ok have read about it but the question is different. I don't have a file system or URL. I am saving the report JSON to the database and in response to the HTTP request I receive Report's JSON object. I need to set that Json to the tool.
Hi, Zain!
Thank you for your reply.
It is possible to directly set the report JSON object into the component in the new Flexmonster()
constructor if you have loaded it before component initialization. Setting the report object after the component is initialized is possible by using the setReport()
API call. You are welcome to check the example: https://jsfiddle.net/flexmonster/L0n1r933/
Using these methods may work if you already have the report loaded to the client from the database, and you need to set it to the Flexmonster instance.
Please let us know if using these methods fits your case.
Best Regards,
Maksym
Hello, Zain!
Hope you are doing well.
Our team is wondering if you had time to check our previous answer about setting a JSON object to a report.
Please let us know if it helped you.
Best Regards,
Maksym
Hey Maksym,
Can I get more information on how to set the report via a Json object.
I'm trying this
public report: Object = {
dataSource: {
type: "json",
data: this.jsonData,
}
}
but I don't get any data.
Hi, Melvin!
Thank you for your question.
We recommend following these steps to find the possible reason for this issue:
this.jsonData
into the console before the line containing the new Flexmonster()
constructor.Feel free to contact us if further assistance is needed.
Best Regards,
Maksym
Hi, Melvin!
Hope you are doing well.
We are wondering if you were able to resolve the issue with loading JSON data into the report.
Looking forward to hearing from you.
Best Regards,
Maksym
Hi, Melvin!
Hope you are doing well.
We are wondering if you were able to resolve the issue with loading JSON data into the report.
Looking forward to hearing from you.
Best Regards,
Maksym
Hey Maksym,
Yes it did. However, when I save the file loaded by json from the backend. I'm saving the key values of each column and not the dimensions.
For example if City and Sales are columns on the pivot table, when I save I want to see the slices as
{
dimensions: "City",
measure: "Sales"
} and not the data, similar to how the save functions work in the demo " https://www.flexmonster.com/demos/js/pivot-table". Right now I'm getting the actual value of each dimension and measure.
I also want to add the data source as a key value to json array.
Please let us know how to fix this.
Regards,
Melvin Paul
Hello, Melvin!
Thank you for your feedback.
We have addressed your new questions in this ticket: https://www.flexmonster.com/question/how-to-change-the-saved-report-format
Best Regards,
Maksym