torsten@1: Ext.define('Lada.controller.Proben', { torsten@1: extend: 'Ext.app.Controller', torsten@4: views: [ torsten@18: 'proben.List', torsten@18: 'proben.Edit' torsten@4: ], torsten@13: stores: [ torsten@13: 'Proben' torsten@13: ], torsten@13: models: [ torsten@13: 'Probe' torsten@13: ], torsten@1: init: function() { torsten@1: console.log('Initialising the Proben controller'); torsten@1: this.control({ torsten@1: // CSS like selector to select element in the viewport. See torsten@1: // ComponentQuery documentation for more details. torsten@18: 'probenlist': { torsten@1: // Map the "render" event to the given function. torsten@5: render: this.onPanelRendered, torsten@5: // Map Doubleclick on rows of the probenlist. torsten@5: itemdblclick: this.editProbe torsten@18: }, torsten@18: 'probenedit button[action=save]': { torsten@18: click: this.updateProbe torsten@1: } torsten@1: }); torsten@1: }, torsten@1: onPanelRendered: function() { torsten@1: console.log('The panel was rendered'); torsten@5: }, torsten@5: editProbe: function(grid, record) { torsten@5: console.log('Double click on ' + record.get('name')); torsten@18: // Create new window to edit the seletced record. torsten@18: var view = Ext.widget('probenedit'); torsten@18: view.down('form').loadRecord(record); torsten@18: }, torsten@18: updateProbe: function(button) { torsten@18: console.log('Click save'); torsten@18: // We only have a reference to the button here but we really wnat to torsten@18: // get the form and the window. So first get the window and form and torsten@18: // the the record an values. torsten@18: var win = button.up('window'); torsten@18: var form = win.down('form'); torsten@18: var record = form.getRecord(); torsten@18: var values = form.getValues(); torsten@18: torsten@18: record.set(values); torsten@18: win.close(); torsten@18: // synchronize the store after editing the record torsten@18: // NOTE: The function 'getProbenStore' will be generated torsten@18: // dynamically based on the Name of the configured Store!!! torsten@18: this.getProbenStore().sync(); torsten@1: } torsten@1: });