torsten@31: var queries = new Array('query1', 'query2'); torsten@6: Ext.define('Lada.controller.Sql', { torsten@6: extend: 'Ext.app.Controller', torsten@6: views: [ torsten@28: 'search.List' torsten@6: ], torsten@8: stores: [ torsten@33: 'Sql', torsten@35: 'Uwb', torsten@35: 'Mst' torsten@8: ], torsten@6: init: function() { torsten@6: console.log('Initialising the Sql controller'); torsten@6: this.control({ torsten@6: // CSS like selector to select element in the viewport. See torsten@6: // ComponentQuery documentation for more details. torsten@31: '#search': { torsten@6: // Map the "render" event to the given function. torsten@6: render: this.onPanelRendered, torsten@6: // Map Doubleclick on rows of the probenlist. torsten@28: select: this.selectSql torsten@31: }, torsten@31: '#SearchBtn': { torsten@31: // Map click event on Button. torsten@31: click: this.search torsten@31: }, torsten@31: '#ResetBtn': { torsten@31: // Map click event on Button. torsten@31: click: this.reset torsten@6: } torsten@6: }); torsten@6: }, torsten@6: onPanelRendered: function() { torsten@6: console.log('The panel was rendered'); torsten@6: }, torsten@28: selectSql: function(element, record, index) { torsten@31: var selection = element.getValue() - 1; torsten@25: console.log('Selected SQL ' + selection); torsten@31: for (var i = 0; i < queries.length; ++i) { torsten@31: var toHide = Ext.getCmp(queries[i]); torsten@31: toHide.hide(); torsten@31: } torsten@31: var toShow = Ext.getCmp(queries[selection]); torsten@31: var buttons = Ext.getCmp('SearchBtnPanel'); torsten@31: this.reset(); torsten@31: toShow.show(); torsten@31: buttons.show(); torsten@31: }, torsten@31: search: function(element, record, index) { torsten@31: var result = Ext.getCmp('result'); torsten@28: console.log('Loading store'); torsten@36: torsten@36: // Get search parameters: torsten@36: var searchParams = {}; torsten@36: if (Ext.getCmp('search').getValue() == 1) { torsten@96: var mst = Ext.getCmp('mst').getValue(); torsten@96: var uwb = Ext.getCmp('uwb').getValue(); torsten@96: if (mst !== null) { torsten@96: searchParams['mst'] = mst; torsten@96: } torsten@96: if (uwb !== null) { torsten@96: searchParams['uwb'] = uwb; torsten@96: } torsten@36: } else { torsten@36: // Get date object an convert it into a timestamp (ms since epoch) torsten@97: var datefield = Ext.getCmp('pbegin').getValue(); torsten@97: if (datefield !== null) { torsten@97: var ts = Ext.getCmp('pbegin').getValue().getTime(); torsten@96: searchParams['begin'] = ts; torsten@96: } torsten@36: } torsten@36: result.getStore().load({ torsten@36: params: searchParams torsten@36: }); torsten@28: console.log('Store loaded'); torsten@25: result.show(); torsten@31: }, torsten@31: reset: function(element, record, index) { torsten@31: var buttons = Ext.getCmp('SearchBtnPanel'); torsten@31: var result = Ext.getCmp('result'); torsten@31: for (var i = 0; i < queries.length; ++i) { torsten@31: var toHide = Ext.getCmp(queries[i]); torsten@31: toHide.hide(); torsten@31: } torsten@31: result.hide(); torsten@31: buttons.hide(); torsten@6: } torsten@6: });