Ext.onReady(function () { var storeStoreConfig = { url: '/appointment/selectStore.action', fields: ['text', 'value'], root: 'data' }; var states = States.drawApptStates('appointmentSelector', 'storeState'); states.addListener('select', function(combo) { if(Ext.get('selStore')) hide('selStore'); var city = Ext.getCmp('storeCity'); city.setValue(''); city.disable(); city.store.load({ params: { state: combo.getValue() }, callback: function() { var city = Ext.getCmp('storeCity'); city.enable(); } }); }); var cityStore = new Ext.data.JsonStore(storeStoreConfig); var city = BFRC.dataCombo.cloneConfig({ id: 'storeCity', store: cityStore, emptyText: 'Select a City', transform: 'storeCity', disabled: true, lastQuery: '', width: 150 }); var storeStore = new Ext.data.JsonStore(storeStoreConfig); if(Ext.get('gridStore')) var stores = new Ext.grid.GridPanel({ id: 'gridStore', store: storeStore, frame: true, renderTo: 'gridStore', width: 300, viewConfig: { forceFit: true, enableRowBody: true }, columns: [{header: 'Address', width: 286, sortable: true, dataIndex: 'text', id: 'address'}] }); var cities = Ext.getCmp('storeCity'); cities.addListener('select', function(combo) { if(Ext.get('selStore')) { hide('selStore'); show('loadStore'); } var state = Ext.getCmp('storeState'); if(Ext.get('gridStore')) stores.store.load({ params: { state: state.getValue(), city: combo.getValue() }, callback: function() { stores.getSelectionModel().selectFirstRow(); if(Ext.get('selStore')) { hide('loadStore'); show('selStore'); } } }); }); if(Ext.get('selectStore')) Ext.get('selectStore').on('click', function() { window.location.href = 'setup.action?storeNumber=' + Ext.getCmp('gridStore').getSelectionModel().getSelected().get('value')+'&mode='; }); var appointmentSubmit = Ext.get('appointmentSubmit'); if(appointmentSubmit) { appointmentSubmit.on('click', function() { window.location.href = '/appointment/store.jsp?storeState=' + Ext.getCmp('storeState').getValue() + '&storeCity=' + Ext.getCmp('storeCity').getValue(); }); } var storeParams = Ext.get('storeParams'); if(storeParams) { var state = document.forms['storeParams'].state.value; var city = document.forms['storeParams'].city.value; if(state) { var storeState = Ext.getCmp('storeState'); storeState.setValue(state); storeState.fireEvent('select', storeState); if(city) { var storeCity = Ext.getCmp('storeCity'); storeCity.setValue(city); storeCity.fireEvent('select', storeCity); } } } });