Hello again,
Recently I've came across an issue related to applying previous expanded state to rows and columns when creating a grid, based on previously saved expanded / collapsed data. I'm saving my previous state using
getReport() method and it more or less looks like this:
getLayout() {
const layout = this.pivotGrid.flexmonster.getReport();
// discarding all non-layout related properties
delete layout.dataSource;
delete layout.creationDate;
delete layout.localization;
return layout;
}
Then I'm trying to apply it whenever I render a component using setReport() method, which more or less looks like this:
generatePivotGrid(pivotGridLayout) {
const { theme, ...report } = pivotGridLayout || {};
this.setTheme(theme);
const flexmonsterReport: Flexmonster.Report = {
dataSource: {
type: 'api',
url: `${environment.prefixPath}/api/flexmonster`,
index: 'stored-procedure-index',
withCredentials: true
},
options: {
showAggregationLabels: false
},
localization:
`${window.location.origin}/assets/flexmonster/langs/${this.translateService.currentLang}.json`,
...report
};
this.pivotGrid.flexmonster.setReport(flexmonsterReport);
}
But the problem is the expanded state is not applied properly. The only thing that seems to work here is the expand all and collapse all state which is saved and applied properly, but whenever I try to collapse / expand only specific rows and / or columns it is not working as expected.
I already saw a similar ticket here https://www.flexmonster.com/question/expand-levels-in-grid/ and I also tried to apply the workaround explained there like that:
flexmonsterReport.slice.expands = {};
if (report?.slice?.expands?.columns?.length > 0) {
flexmonsterReport.slice.expands.columns = [...report.slice.expands.columns];
}
if (report?.slice?.expands?.rows?.length > 0) {
flexmonsterReport.slice.expands.rows = [...report.slice.expands.rows];
}
It works only partially because after that, the rows are expanded properly, but columns still don't work. Is there any possibility to set expanded state using existing get / set report feature on the frontend?
Just to clarify I'm using Flexmonster data server on the backend to generate reports and angular Flexmonster library on the frontend.
Best regards
Hello, Gerd!
Thank you for reaching out to us.
We haven't reproduced the described behavior of expanding and collapsing cells after restoring the report using setReport()
on our side.
Here are some points that may be helpful for further investigating the case on your side:
getReport()
and setReport()
are symmetrical methods. Therefore, we recommend logging the report that was returned from the getter and the one you are passing to the setter and checking if the expands and drills parts look the same.getReport()
and setReport()
. In this case, if the field or field member, which is saved in the expands tuple
, is renamed or not present in the updated data source, that expand won't work.pivotGridLayout
from your code snippet seems to be of a custom data type, so please ensure the report object has the correct structure there.
Hope you will find our answer helpful.
Feel free to get back to us if you have any further questions.
Kind regards,
Solomiia
Hello, Gerd!
Hope you are having a great week.
Just checking in to ask if our previous response was helpful in finding the cause of the described behavior with restoring expands using setReport()
API call.
Do not hesitate to contact us if you have any further questions.
Kind regards,
Solomiia
Hello, Gerd!
Hope everything is well.
Our team is wondering if you had some time to check the suggested points to investigate the described behavior with restoring expands using setReport()
API call. Could you please let us know if there are any updates on the matter?
Looking forward to hearing your response.
Kind regards,
Solomiia
Hello Solomiia, thanks for keeping up with the conversation, sorry for having you wait for so long.
Recently I've had some more time to look at this issue, and still couldn't figured out why columns expansion state is not applied properly
Here's the getReport() json which I save in the db. It's worth to mention that before saving, I'm removing a couple of entries since they are not needed to be saved inside the layout, like described in my previous comment.
{
"slice": {
"rows": [
{
"uniqueName": "FactoryName"
},
{
"uniqueName": "ProductID"
}
],
"columns": [
{
"uniqueName": "[Measures]"
},
{
"uniqueName": "NameShort"
},
{
"uniqueName": "Year"
}
],
"measures": [
{
"uniqueName": "Value",
"aggregation": "sum",
"grandTotalCaption": "Value"
}
],
"expands": {
"rows": [
{
"tuple": ["factoryname.[templates]"]
}
],
"columns": [
{
"tuple": ["nameshort.[kostenart 1]"]
}
]
}
},
"options": {
"showAggregationLabels": false
},
"version": "2.9.55",
"theme": "default"
}
Here is the state I'm applying after fetching the layout from the db. Mind I do fill additional information, like datasource and localization manually while preparing the state before using setReport() (datasource, localization etc. are not saved in the db)
{
"dataSource": {
"type": "api",
"url": "http://localhost:5000/api/flexmonster",
"index": "oct-stored-procedure-index",
"withCredentials": true
},
"options": {
"showAggregationLabels": false
},
"localization": "http://localhost:4200/assets/flexmonster/langs/en-US.json",
"slice": {
"rows": [
{
"uniqueName": "FactoryName"
},
{
"uniqueName": "ProductID"
}
],
"columns": [
{
"uniqueName": "[Measures]"
},
{
"uniqueName": "NameShort"
},
{
"uniqueName": "Year"
}
],
"measures": [
{
"uniqueName": "Value",
"aggregation": "sum",
"grandTotalCaption": "Value"
}
],
"expands": {
"rows": [
{
"tuple": [
"factoryname.[templates]"
]
}
],
"columns": [
{
"tuple": [
"nameshort.[kostenart 1]"
]
}
]
}
},
"version": "2.9.55"
}
I've attached a screenshots which should show a visual state of my grid before saving and after applying the layout - As you can see, the expansion of columns are missing and were not applied properly.
What can I do to further debug my current situation? Although I'm still suspecting that maybe something need to be done inside my custom Flexmonster data server in order to fix this expansion issue, or maybe I'm wrong?
Hope to hear from you soon.
Best regards
Hello, Gerd!
Thank you for getting back to us and for providing a sample report.
We have reproduced the described behavior with restoring expands in columns using a custom data source API. Our Development team will have a closer look at the case and get back to you with the fix with ETA February 5th.
We will notify you about any updates on the matter.
Feel free to reach out to us if any other questions arise.
Kind regards,
Solomiia
Hello, Gerd!
Hope you are doing well.
Our team is happy to inform you that the issue with expands not being restored when using the custom data source API was fixed.
The fix is included in the 2.9.70 version of Flexmosnter: https://www.flexmonster.com/release-notes/version-2-9-70/.
You are welcome to update the component: https://www.flexmonster.com/doc/updating-to-the-latest-version/.
Please let us know if the fix works well for you.
Kind regards,
Solomiia
Hello, Gerd!
Hope you are having a great week.
Our team is wondering if you had some time to test the fix with expands not being restored when using the custom data source API.
Could you please let us know if everything works well after the update?
Looking forward to hearing your feedback.
Kind regards,
Solomiia
Hello Solomiia,
Thank you for tremendous care you put into every support ticket. I'm sorry for a late response, back to your question, yes I was able to upgrade flexmonster as well as your angular wrapper to a 2.9.70 and as far as I can see, the problem has been fixed. Of course I only tested it briefly, and I will get back to you if I find anything more, but I guess it is safe to say that the issue has been resolved.
Best regards,
Hello, Gerd!
We appreciate your kind words greatly and are happy to hear that the expands are restoring well after the fix.
As always, do not hesitate to reach out if any other questions arise.
Best regards,
Solomiia