comparison app/controller/Proben.js @ 18:9e1a40312bbe

Implemented a basic edit dialog. Data will be set to data/proben2.json url which is currently just a dummy file to make to request work. But currently no data is actually saved. The urls need to be replaced with the correct urls in the application backend.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Mon, 06 May 2013 16:41:39 +0200
parents a8efc4b96888
children f9b6de636ad0
comparison
equal deleted inserted replaced
17:3eaeeec2bb28 18:9e1a40312bbe
1 Ext.define('Lada.controller.Proben', { 1 Ext.define('Lada.controller.Proben', {
2 extend: 'Ext.app.Controller', 2 extend: 'Ext.app.Controller',
3 views: [ 3 views: [
4 'proben.List' 4 'proben.List',
5 'proben.Edit'
5 ], 6 ],
6 stores: [ 7 stores: [
7 'Proben' 8 'Proben'
8 ], 9 ],
9 models: [ 10 models: [
12 init: function() { 13 init: function() {
13 console.log('Initialising the Proben controller'); 14 console.log('Initialising the Proben controller');
14 this.control({ 15 this.control({
15 // CSS like selector to select element in the viewport. See 16 // CSS like selector to select element in the viewport. See
16 // ComponentQuery documentation for more details. 17 // ComponentQuery documentation for more details.
17 'viewport > probenlist': { 18 'probenlist': {
18 // Map the "render" event to the given function. 19 // Map the "render" event to the given function.
19 render: this.onPanelRendered, 20 render: this.onPanelRendered,
20 // Map Doubleclick on rows of the probenlist. 21 // Map Doubleclick on rows of the probenlist.
21 itemdblclick: this.editProbe 22 itemdblclick: this.editProbe
23 },
24 'probenedit button[action=save]': {
25 click: this.updateProbe
22 } 26 }
23 }); 27 });
24 }, 28 },
25 onPanelRendered: function() { 29 onPanelRendered: function() {
26 console.log('The panel was rendered'); 30 console.log('The panel was rendered');
27 }, 31 },
28 editProbe: function(grid, record) { 32 editProbe: function(grid, record) {
29 console.log('Double click on ' + record.get('name')); 33 console.log('Double click on ' + record.get('name'));
34 // Create new window to edit the seletced record.
35 var view = Ext.widget('probenedit');
36 view.down('form').loadRecord(record);
37 },
38 updateProbe: function(button) {
39 console.log('Click save');
40 // We only have a reference to the button here but we really wnat to
41 // get the form and the window. So first get the window and form and
42 // the the record an values.
43 var win = button.up('window');
44 var form = win.down('form');
45 var record = form.getRecord();
46 var values = form.getValues();
47
48 record.set(values);
49 win.close();
50 // synchronize the store after editing the record
51 // NOTE: The function 'getProbenStore' will be generated
52 // dynamically based on the Name of the configured Store!!!
53 this.getProbenStore().sync();
30 } 54 }
31 }); 55 });

http://lada.wald.intevation.org