How can we expand 2 levels with dynamic data?
currently we have expand-all function, this will expands all levels, but i need 2 levels of expands...
how can we handle this with dynamic data?
Hello,
Thank you for your question.
The expandAll
API call expands all levels for all hierarchies.
The expandData
API call expands all nodes of the specified hierarchy. Please note, this method works only for CSV, OCSV and JSON data sources.
A possible solution is to implement the desired output manually.
Here is a JSFiddle example for illustration.
In the JSFiddle, you can see how only two levels are expanded for Australia.
Please let us know if you have further questions.
Best Regards,
Vera
It's an old question, the one above, but I think the answer missed the point of the question....how do you expand the two levels WITHOUT API call (json config only) and INDEPENDENT of the value of the dimension on the row...
In other words, from your example, how do you expand ALL Geography and Sales Reason entries WITHOUT knowing what entries will show up by name? Something like, if the report gets populated, expand two levels, and keep three folded, not knowing ahead of time of the possible level values...
Hello, Serban!
Thank you for reaching out to us.
Kindly note that expanding certain levels of the hierarchy via json config is not supported. It is only possible to expand all rows and columns using expandAll: true
slice property.
Feel free to contact us in case of any other questions.
Kind regards,
Solomiia
I don't know if I agree with that...see the fiddle below...I added, in the report section, the expands section, right after the measures section...immediately after the data load, the rows are expanded, basically doing by default what the Expand Data button does on demand.
If I were misunderstood, what I am looking for is a wild card to replace the "&[Australia]" piece of the expand tuple....something to match ANY value of the country field, to expand all the countries...
[Geography].[Geography].[Country].&[Australia]
Edit fiddle - JSFiddle - Code Playground
I found something that might be of use...
https://www.flexmonster.com/api/getmembersasync/
In the sample json results (verified through its fiddle example), one of the nodes' properties shows this:
"parentMember": "category.[(all member)]"
I tried that in the expands, using (all member) as a wildcard, but it's not working.
Am I getting close? 🙂
Even if I am not getting close, can that be a suggestion for a new feature?
[
{
"uniqueName": "category.[accessories]",
"caption": "Accessories",
"parentMember": "category.[(all member)]",
"isLeaf": true,
"children": []
},
...
]
Hello, Serban!
Thank you for your reply.
The proposed idea looks interesting, but currently, Flexmonster does not have any wildcard that can be used in ExpandsObject. As a workaround, it is possible to wrap the logic responsible for expanding the hierarchy inside the reportcomplete
event handler. This way, the hierarchy will be expanded fully automatically.
For JSON/CSV data sources, the simplest solution would be using the previously mentioned expandData()
API call, as shown in this example: https://jsfiddle.net/flexmonster/h3L69rpn/.
Another workaround is to retrieve the needed members with the getMembers()
API call on reportcomplete
, and manually set the expands in the report via the setReport()
API call. Here is a code snippet illustrating the general idea:
reportcomplete: () => {
flexmonster.off("reportcomplete");
let members = flexmonster.getMembers("Category");
let expandRows = [];
members.forEach(member => {
expandRows.push({
tuple: [member.uniqueName]
});
});
let report = flexmonster.getReport();
report.slice.expands = {
rows: expandRows
};
flexmonster.setReport(report);
}
Hope you will find the provided solutions helpful.
Best Regards,
Maksym
Thank you for your answer...yes, this is a workaround, but it's custom programming on our behalf...
To be frank...why would ANYONE use an expand on a hard-coded column value versus expand on the column name, for all values, generic? Expand on Australia, but don't expand on USA...that assumes I know ahead of time Australia deserves expanding, and USA doesn't...but then again, the pivot itself is the one that should describe if Australia or USA are worth drilling down or not...who came first, the egg or the hen? 🙂
So yes, thank you again for the work-around but it would be awesome we got this as a quick config feature...
Hello, Serban!
Thank you for sharing your ideas.
There are cases when expanding by a column value is useful, for instance, to save the exact state of the report after any user interactions on the UI. However, we agree that expanding by a field name in the report config would be an excellent shortcut for some cases that will reduce the size of the report config. We added your suggestion to our customers' wishlist.
Best Regards,
Maksym