cos-archives / hgrid

[UNMAINTAINED] A Javascript-based hierarchical grid that can be used to manage and organize file/folder-like data
Apache License 2.0
23 stars 14 forks source link

Stored expand/collapse state support #78

Closed brianjgeiger closed 10 years ago

brianjgeiger commented 10 years ago

There are views on the OSF (in the feature branch for the project organizer) to add a state for if the node is expanded or collapsed and to save the expand/collapse state on a per-user basis. What would be keen is an option for the HGrid to respect that state when lazy loading (i.e. if expanded == true, load that folder automatically), and to POST the expand/collapse state when someone expands and collapses a node.

brianjgeiger commented 10 years ago

Very cool, though not working for me.

I've added to my Hgrid config, next to where I already had the onExpand and onCollapse callbacks,

        getExpandState: function(folder) {
            return folder.expanded;
        },

Expanded is already an property of my items, and I've verified in other parts of the code that expanded is being set properly. I may have to look at this with you after lunch.

sloria commented 10 years ago

Ok, let's have a look today.

brianjgeiger commented 10 years ago

Very nearly there. If you have a nested folder that's open, and you collapse the containing folder then re-expand it, you will get a doubling of contents when the cached version of the internal folder is expanded as part of the cache, then expanded again because of the flag being set from the lazy loading (or something similar to that).

brianjgeiger commented 10 years ago

Hmmmm. It's happening for me whenever I collapse and expand a node. Anything inside it is being re-added.

sloria commented 10 years ago

Should be fixed now, eh @brianjgeiger ?

brianjgeiger commented 10 years ago

Working great