• save state

    By Peter Kempf 2 decades ago

    I noticed that the SaveState function did not save the selected document. For example if you expanded a categorized column, then opened a document, then "closed" the document by going back, the view was collapsed.



    In the SaveState function the values for selected entry were not picked up from the cookie:

    this.selectedEntryPosition = "";//cookieValues[3];

    this.start = "";//cookieValues[3];



    When I enable them it appears to work at first. But when I used the scroll bar, the behavior is unpredictable.



    Any thoughts on why this is happening?

    • Save State Limitations

      By Jeremy G Hodge 2 decades ago

      Hey Peter…



      The save state functionality is rather limited in scope … from the looks of it, it can save 4 things, what column is sorted,either ascending or descending (thats 2), the selected position, and if it was expanded all …



      This poses some problems, for example, when you expand or collapse certain sections, etc. I think that to fix the problem there is going to be a little overhaul needed to the save state, for example each individually expanded section should be recorded, as well as the current scroll position, etc. I'm going to try to address the save state in the next release to see if we cant do that.



      Thanks



      jeremy

      • Scroll up....

        By Peter Kempf 2 decades ago

        One more observation:

        When I enable the loadState to load the selectedPosition

                        this.selectedEntryPosition = cookieValues[3];<br/>
                        this.start = cookieValues[3];<br/>
        

        The down scroll button works, but the up does not.

        After a cursory reading of the scroll code, it appears to rely on a stack of previous start entries for the scroll up. So if you open a document, then "go back", the start position is restored from the cookie, but the stack is gone from memory so the scrolling up does not work and defaults to the beginning (in my case a collapsed view).

        Not sure how to fix that, but support really needs to be added to be able to open a document then go back to the view without losing that state.

        • re: scroll up...

          By jason a thomas 2 decades ago

          Hi Peter,



          That is why I had those lines commented out:( I regret not adding more documentation in the script library there to explain that. I could never figure out a way to get the saveState working completely.

          You would have to get rid of the previousEntries stack that I created and replace it with something else.

          The problem is that using ReadViewEntries xml and starting in the middle of the view, let's say &Start=50, you'll never be able to get to the top of the view because there is no way for the javascript to "know" what the top of the view is. You might think you can use &Start=1 as the starting point, but if the user doesn't have read access to the first 49 documents in the view, then when you scroll up you'll still be starting #50, so the view will always appear to need to be scrolled up.

          And it gets even worse when you try to start in the middle of a categorized or response hierarchy view.



          I ultimately decided that always opening the view at the start was the simplest way. Hopefully Jeremy can succeed here where I could not. I'm glad to see a tiny (very tiny I s'pose) community building around this code

          • Load State & Scroll Up

            By Jeremy G Hodge 2 decades ago

            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

          • Compressor & Cruncher

            By Jeremy G Hodge 2 decades ago

            Also Jason, for consistency, what compressor/cruncher did you use to generate the compressed and crunched versions of the scripts…



            Thanks

          • a ScrollUp solution variant

            By Alexander Yesafov 2 decades ago

            Hello!

            At first, thanks for NotesView2. it's great!!!

            I've developed a solution for ScrollUp problem. It's a quick rough solutiion, not very elegant, but works :-)

            I wrote an lotusscript agent, which takes current position in view and generates PreviousState history for specified number of steps back. Now I'am solving a problem with scrollbar.

            I can provide you with agent code and view script modifications.

            Best Regards!

            Alexander