Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #16
    I'm now using the JSNI method I showed in the previous post along with JSON.encode and saving the resulting string.
    Code:
    String combinedState = JSON.encode(getCombinedState(getViewState(), getHiliteState()));
    The saved string looks like this ...
    Code:
    {     "viewState":"({selected:null,field:\"[\\r    {\\r        name:\\\"_checkboxField\\\", \\r        width:28\\r    }, \\r    {\\
    
    ... and on and on (the ListGrid has a lot of fields) and ending like this
    
      sortSpecifiers:[\\r        {\\r            property:\\\"ItemNumber\\\", \\r            direction:\\\"ascending\\\"\\r      }\\r    ]\\r})\"})",      "hiliteState":"([\r    {\r        \"fieldName\":\"IRET\", \r        \"criteria\":{\r            \"fieldName\":\"IRET\", \r            \"operator\":\"greaterThan\", \r            \"value\":10\r        }, \r        \"textColor\":\"#D50101\", \r        \"cssText\":\"color:#D50101;\", \r        \"id\":0\r    }\r])" }
    All looks good. And when I read the string back I do the following.
    Code:
    JavaScriptObject savedStateJSO = JSON.decode(savedState);
    String viewState = JSOHelper.getAttribute(savedStateJSO, VIEW_STATE);
    setViewState(viewState);
    String hiliteState = JSOHelper.getAttribute(savedStateJSO, HILITE_STATE);
    setHiliteState(hiliteState);
    The object is decoded and the getAttribute() calls return the following strings, as expected.

    JSOHelper.getAttribute(savedStateJSO, VIEW_STATE)
    Code:
    ({selected:null,field:"[\r    {\r        name:\"_checkboxField\", \r        width:28\r    }, \r    {\r        name:\"ItemNumber\", \r        width:null\r    }, \r    {\r        name:\"IDES\", \r        width:null\r    }, \r    {\r        name:\"IVST\", \r        width
    
    .... and on and on as expected
    JSOHelper.getAttribute(savedStateJSO, HILITE_STATE)
    Code:
    ([
        {
            "fieldName":"IRET", 
            "criteria":{
                "fieldName":"IRET", 
                "operator":"greaterThan", 
                "value":10
            }, 
            "textColor":"#D50101", 
            "cssText":"color:#D50101;", 
            "id":0
        }
    ])
    The hilite state is being restored correctly now. But the view state is not. The string is passed to setViewState() which executes without error, but the ListGrid layout doesn't change to the column order that was saved.

    Comment


      #17
      I spoke too soon. It must have something to do with stepping through in debug. After removing all of my breakpoints and trying again it works. Thanks again for the help.

      Comment


        #18
        Does the viewState include "Group By" state also? I would like to save "Group By" user preference. I don't see it in the showcase example. Any ideas?
        Last edited by ideanator; 21 Dec 2010, 15:48.

        Comment

        Working...
        X