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

Flexmonster custom data source API reload data

Closed
Massimo asked on October 1, 2020

Hello,
I’m trying use Flexmonster custom data source API, but I don’t understand how i can force reload of data.
 
 
Thanks
Best regards

9 answers

Public
Massimo October 1, 2020

Hello,
I have also another problem, the “update” isn’t triggered after the field’s popup editing.
Do you have any ideas?
 

Thanks
Best regards

Public
Sengupta October 2, 2020

I have a very similar question, 
“runQuery” will force a refresh of data but it will also reset/rebuild the view
I need my view to remain same (i.e. expanded, scrolled, no resorting, etc)
What is equivalent “updateData” for custom data source API?
Regards

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster October 2, 2020

Hello, Massimo,
 
Thank you for giving us some time
 
If you require to reload the data for the client-side, we suggest using the updateData API call. It updates data for the report without cleaning the report. Only the Data Source Object is updated, whereas the slice, all defined options, number and conditional formatting, the scroll position stay the same.
 
Concerning the update event, we want to inform you that we did not manage to reproduce the issue. Please note that the update event is triggered after the “Apply” button of the Field List is pressed and all the changes are applied. You are welcome to see the JSFiddle we have prepared for the demonstration.
In case you are still facing the issue, please provide us with an example where it would be reproducible.
 
Please let us know if it works for you.
Our team is looking forward to hearing your feedback.
 
Kind regards,
Illia

Public
Sengupta October 2, 2020

I took the JSFiddle example at http://jsfiddle.net/flexmonster/j1c6rd24/

  1. added a button in the HTML


<div>
<button id=”btn4″ onclick=”refreshCustomData()”>Refresh Custom DataSource</button>
</div>

 
2. Added a function in the JavaScript

function refreshCustomData() {
pivot.updateData({
dataSource: {
type: “api”,
url: “http://olap.flexmonster.com:9202/api/cube”,
index: “fm-product-sales”
}
}, {keepMembersOrder: true, ignoreScroll: false});
}

 
3. Run 
4. Click the button “Refresh Custom DataSource” (at bottom)
Report goes BLANK
Please help, what am I doing wrong
 
 
 

Public
Massimo October 2, 2020

Hello,
If I understand well the updateData call is used if I have the data, like you documentation
flexmonster.updateData({ data: jsonData });
In this case I don’t have the data, I need to trigger the flexmonster to update the data like the first load.
 
Concerning “update” the problem is the follow, I have two events OnPopupOpen and onPopupClose.
onPopupOpen(): void {
    this.pivot.flexmonster.on(“update”, () => {
      this.saveCurrentConfiguration();
    });
  }
  onPopupClose(): void {
    this.pivot.flexmonster.off(“update”);
  }
With the new Custom Data Source API the event “update” is triggered after the query “select” while my second event “onPopupClose” is triggered before the “select”.
 
Thanks
Best regards

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster October 2, 2020

Hello, Sengupta,
 
Thank you for reaching out to us and for providing code snippets.
 
We want to explain that the updateData API call’s first parameter has the same structure as the Data Source Object. It must not include the dataSource object itself.
The provided code sample should be changed in the following way:

function refreshCustomData() {
  pivot.updateData({
    type: "api",
    url: "http://olap.flexmonster.com:9202/api/cube",
    index: "fm-product-sales"
  },
  {
    keepMembersOrder: true,
    ignoreScroll: false
  });
}

Please see the JSFiddle we have prepared for the demonstration.
 
Our team hopes it works for you.
Please contact us in case other questions arise.
 
Regards,
Illia

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster October 5, 2020

Hello, Massimo,
 
Thank you for providing us with details.
 
Concerning the data updating.
In case the data needs to be loaded to the component right after the initialization, pass the corresponding report with a Data Source Object specified:

new Flexmonster({
report: {
dataSource: {
type: "api",
url: "https://olap.flexmonster.com:9500",
index: "fm-product-sales"
},
...
},
...
}

Next, to update the data from the same data source, use the updateData API call with the corresponding parameters:

flexmonster.updateData({
type: "api",
url: "https://olap.flexmonster.com:9500",
index: "fm-product-sales"
})

 
In case the custom data source API is used, there is no need to preload the data. Just pass the same connection parameters (type, url, index) to make Flexmonster perform the update from the specified endpoint.
 
Concerning the update event.
We want to explain that it is triggered when the component loaded data. It means you unsubscribe from the event earlier than it is dispatched:

onPopupClose(): void {
this.pivot.flexmonster.off("update");
}

As a result, the configuration is not saved.
 
We suggest using the reportchange event instead. This event is triggered right after the report itself is changed. It does not wait until the data is loaded. As a result, it will be triggered before the fieldslistclose event.
 
You are welcome to see the example we have prepared. It demonstrates the usage of the reportchange event.
 
Please let us know if it helps.
Do not hesitate to contact us in case further questions arise.
 
Kind regards,
Illia

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster October 12, 2020

Hello, Massimo,

Our team is wondering whether the proposed solutions work for you.
 
We are looking forward to your feedback.
 
Best regards,
Illia

Public
Massimo October 12, 2020

Hello Illia,
it’s works correctly.
 
Thanks
Best Regards
 

This question is now closed