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

UpdateData() API call and the slice object

Re-Open
Nir Nimova asked on November 23, 2020

Dear FlexMonster team,
 
We’ve just acquired a FlexMonster license and even after fetching the latest version we are still facing an issue with updateData API call.
I have stumbled upon the following post from approximately a year ago:
https://www.flexmonster.com/question/updatedata-resets-the-filter-defined-in-the-slice/
It says that updateData() API call does not reset the slice object and that you guys didn’t have the possibility to change the described behavior back then.
Is this still not possible today?
I have the following code:

    updateFlexMonsterData(proc, sp_params = null) {
this.api.executeAndRetrieveDynamicSQL({
SQL: proc,
SP_Params: sp_params,
isMetaDataRow: true,
isReport: true
}).then(res => {
let flexData = this.modifyJsonForFlexMonster(res.sqlResult);

if (editableReportState.pivot.flexMonster === null) {
editableReportState.pivot.flexMonster = new Flexmonster({
container: "pivotModalContainer",
toolbar: true,
componentFolder: "/js/flexmonster/",
report: {
dataSource: {
data: flexData
},
options: {
grid: {
type: 'classic'
},
datePattern: 'dd/MM/yyyy HH:mm:ss'
}
},
licenseKey: "XXX",
beforetoolbarcreated: toolbar => {
let tabs = toolbar.getTabs();
toolbar.getTabs = function () {
delete tabs[0];
delete tabs[1];
delete tabs[2];
return tabs;
};
}
});
}
else {
editableReportState.pivot.flexMonster.clear();
editableReportState.pivot.flexMonster.updateData({ data: flexData });
}
});

The first time I create a FlexMonster object without a slice object defined, it works perfectly fine.
Whenever I use updateData call, I expect that same behavior, but I see something else. (same filters and columns)
The data is completely different.
I want to avoid refreshing the page or doing a postback every time a user chooses a report. (I have an html select tag with reports – using JSON datasource)
Please inform me, is there a solution or a more elegant workaround for this?
Regards,
Nir

12 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster November 23, 2020

Hello, Nir,
 
Thank you for reaching out to us.
 
In case we understand correctly, your requirement is to change the data source for the existing instance of Flexmonster and clear the configuration (chosen fields, filtering, sorting, etc.).
If our assumption is correct, we suggest checking out the connectTo API call. The updateData method serves to update data for the report without cleaning the configuration. In its turn, the connectTo API call clears the existing configuration.
 
If you want to change the data source and adjust a new configuration simultaneously, use the setReport method. It allows changing the data source and applying a new configuration at the same time.
 
Please let us know if it helps.
Feel free to contact us in case any additional questions arise.
 
Best regards,
Illia

Public
Nir Nimova November 24, 2020

Hi Illia,
Thank you for the answer.
Unfortunately, neither the connectTo nor the setReport API’s worked for me.
Both calls resulted in exact same behavior:

editableReportState.pivot.flexMonster.connectTo({ data: flexData });

editableReportState.pivot.flexMonster.setReport({
dataSource: {
data: flexData
},
options: {
grid: {
type: 'classic'
},
datePattern: 'dd/MM/yyyy HH:mm:ss'
}
});
Public
Nir Nimova November 24, 2020

I am just looking for the same behavior I am getting when I declare a FlexMonster object initially.
Right now I am using a postback to resolve this, I hope to avoid this with your help.
Please let me know if there is a solution for this.
Regards,Nir

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster November 25, 2020

Hello, Nir,
 
We want to explain that we did not manage to reproduce the issue.
 
Therefore, we prepared an example that demonstrates the difference between updateData and setReport API calls. You will find the list of steps to show the difference between the two methods.
The setReport method applies a new report to the existing Flexmonster instance. It can be used to achieve the same behavior as with initialization.
 
If it does not work in the same way for your case, we suggest modifying the provided JSFiddle in the way the issue is reproducible.
 
In case setReport does not cover your requirements, we want to ask for the details on this point. How is the behavior different from the desired one?
 
We are looking forward to hearing from you.
 
Best regards,
Illia

Public
Nir Nimova November 26, 2020

Hello Illia,
 
Thank you for the demonstration.
I can see that the jsfiddle works perfectly fine, but unfortunately in my case it doesn’t.
I got attached message when initially using this code block:

editableReportState.pivot.flexMonster.clear();

editableReportState.pivot.flexMonster.setReport({
dataSource: {
data: flexData,
options: {
grid: {
type: 'classic'
},
datePattern: 'dd/MM/yyyy HH:mm:ss'
}
});

Attachments:
Screenshot_3.jpg

Public
Nir Nimova November 26, 2020

After dismissing the error, it didn’t work.
I changed the type to “compact” in the code and it somehow worked.
Problem is, it wasn’t very consistent. 
Some data it works, some doesn’t, sometimes it gets stuck, sometimes you have to click “grid” button in order to see changed results.
 
I included an attachment with one of the phenomena I am encountering while using setReport.
 
Please advice,
 
Regards,
Nir

Attachments:
Screenshot_4.jpg

Public
Nir Nimova November 26, 2020

One more thing worth mentioning:
There is no error being thrown to the browser console while this is happening

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster November 27, 2020

Hello,
 
Thank you for your feedback.
 
Concerning the alert with a confirmation, we want to explain that it is displayed when there is no enough space to display the classic form. In this case, Flexmonster will change the form to compact automatically.
To avoid this behavior, we suggest increasing the dimensions of the component’s container. Another possible solution is to specify the format to compact by default.
 
Also, we want to explain the clear method does not need to be called before applying the report. It is a redundant step because the previous configuration is cleared after calling the setReport method.
 
Concerning other unexpected results, we want to explain that we did not manage to reproduce them on our side.
Please send a sample project where the problem would be reproducible. Another option is to provide us with access to your environment so that we could test the behavior on our side.
 
We are looking forward to hearing from you.
 
Kind regards,
Illia

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster December 9, 2020

Hello,
 
Our team is wondering whether you had some time to prepare a sample that would demonstrate the issue.
 
We are looking forward to hearing from you.
 
Kind regards,
Illia

Public
Nir Nimova December 10, 2020

Hi Illia,
 
We will setup an environment for you to access in the next few days.
 
Regars,
Nir

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster December 21, 2020

Hello, Nir,
 
We are reaching out to ask if you had the possibility to prepare the mentioned environment.
 
Our team is looking forward to hearing from you.

Regards,
Illia

Public
Nir Nimova December 22, 2020

Hi Illia,
Things have changed in our business logic, so this is no longer relevant.
Thanks for your support and time.
Regards,
Nir

Please login or Register to Submit Answer