How to get row count of expandable / collapsible rows

Closed
Yosef asked on April 4, 2024

I'm adding an Expand All and Collapse All options to the context menu and trying to show / hide them when appropriate according to whether the rows are all collapsed or expanded.

Can you help me achieve this?

I can get the expanded rows from flexmonster.getReport().slice.expands However this does not help me determine whether all rows are expanded or collapsed.

I tried flexmonster.getData() to get the row data however this is returning undefined.

3 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster April 5, 2024

Hello, Yosef!

Thank you for reaching out to us.

We suggest implementing these "Expand All" and "Collapse All" functionality using the expandAllData and collapseAllData methods.

The expandAllData API call would replace the existing expands the expands object to contain expandAll: true property. This property indicates that all fields are expanded by the "Expand All" context menu tab, providing an appropriate condition to hide it. When certain cells are manually collapsed after the expandAllData is called, they would be added as expands alongside the expandAll property. While this approach would not work when the user manually expands all members, such an edge case is unlikely if your table contains many expandable members. 

The condition for hiding the "Collapse All" context menu tab would be even easier to implement since the expands object is automatically removed from the report when all data is collapsed. In this case, it does not matter whether the data is collapsed manually or by using API calls.

Additionally, we would like to mention that the getData API call does not explicitly return data. Instead, the grid data is passed to callback handlers when the data on the grid is loaded or updated. We strongly recommend using this method only for integrations with third-party charting libraries.

Please let us know if our answer helped you.

Best Regards,
Maksym

Public
Yosef April 8, 2024

Thanks Maksym for the detailed response.
 
"The condition for hiding the "Collapse All" context menu tab would be even easier to implement since the expands object is automatically removed from the report when all data is collapsed. In this case, it does not matter whether the data is collapsed manually or by using API calls."

One things to note is that for the Collapse All  menu tab, the expands object is not removed when all the cells are collapsed manually. This means that if the user manually calls "Expand All" or "Collapse All" and then either collapses all manually, or expands all manually, there doesn't appear to be away to tell from the API that all is now collapsed or expanded.

Your answer helps in a limited sense and it doesn't work in all cases. 

Public
Maksym Diachenko Maksym Diachenko Flexmonster April 8, 2024

Hello, Yosef!

Thank you for your feedback.

Our apologies for the inaccuracy in our previous response. As you correctly mentioned, the expands object is not removed when the cells are manually collapsed after expandAllData is called. 

We understand your frustration with the corner cases where our proposed solution may not work as expected. We want to assure you that we have carefully considered various alternatives, and despite these limitations, this solution remains the most viable option for this scenario. 

Our team is looking forward to hearing from you.

Best Regards,
Maksym

This question is now closed