Threaded View

  1. #1
    Ext User
    Join Date
    May 2008
    Posts
    110
    Vote Rating
    0
    illuminum is on a distinguished road

      0  

    Default [solved] Trouble restoring state on a ComboBox

    [solved] Trouble restoring state on a ComboBox


    How do I restore the state on a ComboBox? I've setup the code that is pasted below and I can see in Firebug that the 'statesave' event does indeed fire but 'staterestore' never does. I can also see a cookie stored but all I can inspect as far as that goes is the encoded session id--I'm not sure if I'm supposed to be able to see actual objects and values in the cookie or not. Again, back to the basic question, what exactly do I need to do to restore the state so that upon reloading the application, the application's stateful components conspicuously restore the options/values that were set within them?

    Here is my code:

    Code:
        var combo = new Ext.form.ComboBox({
            id: 'myCombo',
            emptyText: 'Select Foo',
            title: 'Title',
            store: myStore,
            mode: 'remote',
            triggerAction: 'all',
            displayField: 'name',
            valueField: 'rendition_id',
            lazyInit: false,
            stateful: true,
            stateEvents: ['select','change'],
            queryDelay: 1
        });
        combo.on({
           statesave: { // I can see that this fires correctly in firebug
                fn: function() {
                    console.log('statesave');
                }
            },
           staterestore: { // Though this never fires
                fn: function() {
                    console.log('staterestore');
                }
            }
         });
    Code:
        <script type="text/javascript">
          Ext.onReady(function() { 
              Ext.BLANK_IMAGE_URL = 'assets/ext/resources/images/default/s.gif';
               Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
                  expires: new Date(new Date().getTime()+(1000*60*60*24*1))
              }));
              Ext.QuickTips.init();
              App.init();
          });
        </script>
    Last edited by illuminum; 8 Jul 2008 at 9:40 AM. Reason: made the code more generic and concise

Thread Participants: 2