Function needed: saves slice and tableSize and formats then loads and applies to new data

Answered
Franz J Fortuny asked on March 29, 2018

We have gone crazy trying to suggest a practical way to use the component:

  1. User opens report (json form a database query) and fiddles with it until it looks ok for rows, columns, measures and tablesizes and formats.
  2. User saves ONLY slice and tablesize and formats, BUT NOT data
  3. User comes back later and brings json from database, new data from the same report. Updated data...
  4. User opens the slice-format etc file and applies it to loaded new data

Honestly, maybe it is too late, but we have gone crazy trying to find a way to do that.
Please, if you know of a way to do what we need, explain. Thanks.
This used to be possible by saving the xml structure files and then opening it: it would immediately apply to the loaded data. That used to be so simple and easy!
New version should BUILD on old versions, but NEVER wipe out what used to be good.

7 answers

Public
Iryna Kulchytska Iryna Kulchytska Flexmonster March 29, 2018

Hello Franz,
 
Thank you for posting your question.
 
There could be several approaches to the application of slice, tableSizes and formats to new data.
 
The first approach requires providing data to the component by accessing a URL of a server-side script that returns data from the database in JSON format.
If it is a viable option for your application, then filename parameter can be used to provide JSON data, as follows:

{
"dataSource": {
"dataSourceType": "json",
"filename": "https://your_script_that_returns_json_data"
},
"slice": {
...
},
"formats": [
...
],
"tableSizes": {
...
}
}

In this case, a user saves the whole report (slice/formats/tableSizes/etc and dataSource with the URL of a server-side script that returns data).
Setting this report later using setReport() API call will apply the slice/formats/tableSizes/etc from this report to the new data provided by the script "https://your_script_that_returns_json_data".
I have attached a sample report file to this answer (report-with-json-from-url.json)
Could you please let me know if this approach could work for you?
 
If you prefer to supply JSON data to the component through data parameter, as follows:

{
"dataSource": {
"data": jsonData
}
}

then, in this case, the scenario can be implemented in a different way. If this option of providing JSON data works better for you, please let me know, and I will provide you with the instructions on this approach.
 
I'm looking forward to your answer.
 
Kind regards,
Iryna
 
 

Public
Franz J Fortuny March 29, 2018

I was unable to find the attached report mentioned by you. It is a different approach and also similar reports might requiere different views for different users. I am working on a different solution right now. Also the URL to execute a report must be sent by POST, because of sensitive data that would be visible in the URL.

  1. User will call raw report
  2. User will define view of report
  3. User will save the slice and others associated with report and user's credentials.
  4. Next time user needs the report it will com with data plus slice to reformat
  5. User will be able to save as usual full report and data locally

I hope this approach will work.

Public
Franz J Fortuny March 29, 2018

Please the filename URL will be POST or GET?
We need to send several parameters and we are doing that right now when the user selects the raw data report she needs.
The data is sent in the form of JSON and the first slice is auto created. Very simple.
Please do send any other idea you may have. The idea is that the user's designed view can be easily applied to new data at all times. The user will be able to create more than one slice version.

Public
Tanya Gryshko Tanya Gryshko Flexmonster March 30, 2018

Hello, Franz,
Thank you for providing more details about your use case.
Let me suggest you the following flow:

  1. User opens the raw report. This report needs to have dataSource section, otherwise, it is not possible to configure slice, format, etc.
  2. User fiddles with the report until it looks ok
  3. User saves view (slice, format, etc.). This can be achieved by getting the current report via getReport() method, removing dataSource section, and saving this config.
  4. User opens new data source and wants to apply the previous view. He selects the necessary view, and the new report is composed by merging getReport().dataSource with view configuration. Then this new report can be set via setReport().

So, as you can see, saving the full report, as usual, can be achieved with getReport(); saving current view should be done the same way, you just need to remove dataSource subobject.
Concerning your question about filename property, we recommend specifying all the necessary parameters here. For example:

filename: "http://olap.flexmonster.com/compressor/demo.php?parameter1=value1&parameter2=value2"

filename is either a URL to CSV or JSON file or a URL to the server-side script which generates data. Request Method for filename parameter is GET.
Please note that suggested scenario allows creating more than one slice version and saving it the way you need.
Let me know whether you were able to implement everything successfully.
Regards,
Tanya

Public
Tanya Gryshko Tanya Gryshko Flexmonster March 30, 2018

Franz,
I would also like to mention that if GET Request Method of filename parameter does not work for your case, you can set JSON data via dataSource.data property:

{
"dataSource": {
"data": jsonData
}
}

In such case, the way how you get JSON data is completely up to you.
Regards,
Tanya

Public
Franz J Fortuny March 30, 2018

The app is already doing the following:

  1. User selects a raw data report supplier. Just row records in JSON format.
  2. The JSON formatted rows are set as data to the Flexmonster report being created.
  3. Report is shown and USER fiddles with report until it looks ok for her.
  4. User clicks on button that executes a function that:
    1. Removes datasource section
    2. Stores the remaining to the remote database

Next time the user calls the same raw report, at the database it is recognized that such ID (of user) when calling the IDREPORT, should come already formatted with previously chosen slice and formats.
User will be given a list of previously created slices, with different descriptions, created by herself and perhaps, created for the whole company, maybe without permission to modify it.

So, the server sends the raw data as the datasource section, which is added to the JSON structure previously saved.
I am working on the above process right now. Hopefully, it will work. I will let you know and invite you to test it.

Public
Tanya Gryshko Tanya Gryshko Flexmonster March 30, 2018

Franz,
We are glad you have managed to configure your app.
Let us know how the further process goes.
Regards,
Tanya

Please login or Register to Submit Answer