nagarajanchinnasamy/subtotal

Initial Expand/Collapse Behavior

Opened this issue ยท 9 comments

Hi Nagarajan , first of all many thanks for your great work on pivot table. I found it very useful but there is something I wish to achieve which is not yet supported currently, correct me if I am wrong. I wonder if we can set the default expand/collapse behavior in the first place. Right now when I expand a parent element, all levels of child elements will be expanded by default, making the tree unnecessarily long when one does not need to see all child elements. I would like to have this manually expanded.

Thanks.
Pang

Hi @gemiur, you are welcome :)

If you collapse the rows/columns initially using collapseRowsAt and/or collapseColsAt options, then the descendant elements can only be expanded/collapsed manually.

Please check the behavior in this example

Let me know if this meets your expectations.

Hi @nagarajanchinnasamy ,

Let's use your example to explain my situation. What I wish to achieve is if I set collapesRowsAt to 0, and when expanding Female, only Province elements will be expanded, Age Bin will still be hidden. What it happens now is both Province and Age Bin are expanded automatically. I have 4 items in the Row, last item has many child elements in it so I don't want it to automatically expand as this will make the entire table very long.

Hope this makes sense.

Thanks.
Pang

Hi @gemiur,

Understood the issue now :). Will take it up as a defect.

Thanks for your feedback.

After further analysis, i realized that this may not be a defect. By default, the table is built with all rows and columns expanded so that user doesn't have to click at every level to get everything expanded. When collapseAt option is used, a click at that level is mimicked. This just hides the sub items. Doesn't really collapse them. Hence the current behavior.

Still thinking how your requirement can be met.

Hi @nagarajanchinnasamy ,

Thanks for your reply.

In that case, is it possible to have an expandAll option so that when it is set to false all child items will be hidden ? Imagine this as a normal directory tree in Windows Explorer, I wouldn't want all child elements get expanded each time I open the Explorer, it will be very messy :)

@gemiur

Agree. An option to choose the initial behavior should help.

Thanks for your feedback.

After further thought, I chose to experiment with using collapseAt options. Last commit in branch v1-11.0 handles the column collapsing. Still work in progress. Don't touch the rows yet :)

Column Collapsing, Row collapsing and showing row subtotals at the bottom implemented. Please check latest v1-11.0 branch. Pending: Row expansion when displaying subtotals at the bottom.

Am using examples/210_collapse_rowscols.html to test and debug.

@gemiur and friends,

Please check the latest version at v1-11.0 branch. I will merge this branch into master after your confirmation.

Thanks :)