As of this morning, I've got it working in beta code right now …
What i had to do was essentially create an allExpanded stack that kept track of all expanded categories (or collapsed if in "expandAll" mode), and then create a stack of URLs called by loadData() and save those new stacks along with the previousStarts stack to the cookie on a saveState(), then on loadState, I replay the calls to loadData to reload the XML data from the browser's cache, restore the previousStarts stack, then call expand()/collapse() to restore the state of the expanded/collapsed cateogries, set this.start to the saved value of this.start (instead of selectedEntry or in some cases a hard-coded "1"), and everything loads up as it was in the previous state. There was some other changes here and there such as execution order in loadState() etc, but thats the general idea. I'm still testing, verifying etc, and I have a few bugs to work out with the implementation of column totals, but i should have the release up soon, probably sometime this week.
The biggest concern i have right now is that larger views with lots of calls to loadData could exceed the 4k limit on a cookie, so i'd recommend larger views pull larger amounts of data at a time, and make sure you test the limits of the 4k cookie on the URL stack. If anybody has a good routine with low overhead to compress a single string, let me know, i'd like to implement it for the URL stack when saved, but i havent played with compressing a single string before, and i couldnt find a good routine to concept from…
I've also added a stateTimeout property to the NotesView object so you can control how long you want to save the state … since loadState replays the XML from a previous state, there is a greater possibility of having inconsistent data between an initial load of the view, and the subsequent results of calls to loadData from the view. Basically, the idea is if the time set in stateTimeout expires, it expires all state data and loads the view in a "fresh" state as if no previous state existed (all collapsed, starting @ row 1). This can also help to limit the size of the URL Cache stack. The stateTimeout is set to 15 mins, and the clock starts ticking with every call to saveState, so you basically would have 15 mins from any scroll, selectedEntry change, data load, document open, etc. To change ths time you'd just modify stateTimeout like this:
// assuming oView is your NotesView2 object…
oView.stateTimeout = { years: 0, months: 0, days: 0, hours: 1, mins: 30, secs: 0);
that would basically increase the state time out to an hour and a half….
Well, back to it …
Jeremy