How to update data

Resolved
Mantas asked on August 24, 2022

Hello,
I'm trying update data:
pivot.updateData({
  type: "json",
  filename: "/api/Pivot/LoadData?table=MyTable",
  mapping: "/api/Pivot/LoadMapping?table=MyTable"
});
First time it works ok. But if I execute it second time (mapping or data can change in realtime), pivot updates mapping, but not updates data. What am I missing?

3 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster August 25, 2022

Hello, Mantas!

Thank you for writing to us.

Kindly note that the updateData API call updates the data only when the dataSource parameter differs from one already set inside the report. This is the reason why data is updated only for the first time.

We suggest appending the current UNIX timestamp to the filename parameter. This simple workaround guarantees the uniqueness of the URL, and data will be updated. You are welcome to check the example: https://jsfiddle.net/flexmonster/7ny0bcrp/

Feel free to contact us if more questions arise.

Best Regards,
Maksym

Public
Mantas August 25, 2022

I found workaround:
var index = 1;
function refresh() {
  index++;
  pivot.updateData({
    type: “json”,
    filename: “/api/Pivot/LoadData?table=MyTable&” + index,
    mapping: “/api/Pivot/LoadMapping?table=MyTable&” + index
  });
}
 
If I add index only to mapping - it does not refresh data. If I add index only to data - components does not refresh data anyway. The only working solution - add to both of them.

Public
Maksym Diachenko Maksym Diachenko Flexmonster August 26, 2022

Hi, Mantas!

Thank you for your feedback.

We are glad to hear that this workaround works for you.
You are welcome to write to us in case of any other questions.

Best Regards,
Maksym

Please login or Register to Submit Answer