Need a special offer?Find out if your project fits.
+

Expand levels in grid

Answered
vasu asked on April 17, 2019

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?

8 answers

Public
Vera Didenko Vera Didenko Flexmonster April 18, 2019

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

Public
Serban Vasile February 3, 2023

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...

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster February 6, 2023

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

Public
Serban Vasile February 6, 2023

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

Public
Serban Vasile February 8, 2023

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": []
  },
  ... 
]
Public
Maksym Diachenko Maksym Diachenko Flexmonster February 10, 2023

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

Public
Serban Vasile February 15, 2023

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...
 

Public
Maksym Diachenko Maksym Diachenko Flexmonster February 17, 2023

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

Please login or Register to Submit Answer