comparison app/controller/grid/Messwert.js @ 590:e440b66a859f

Added grid (+controller) for messwerte.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 11 Mar 2015 15:23:16 +0100
parents
children f2742f9b5a64
comparison
equal deleted inserted replaced
589:4c97717b92da 590:e440b66a859f
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */
8
9 Ext.define('Lada.controller.grid.Messwert', {
10 extend: 'Ext.app.Controller',
11
12 init: function() {
13 this.control({
14 'messwertgrid': {
15 edit: this.gridSave
16 },
17 'messwertgrid button[action=add]': {
18 click: this.add
19 },
20 'messwertgrid button[action=delete]': {
21 click: this.remove
22 }
23 });
24 },
25
26 gridSave: function(editor, context) {
27 context.record.save({
28 success: function() {
29 context.grid.store.reload();
30 context.grid.up('window').initData();
31 },
32 failure: function() {
33 // TODO
34 }
35 });
36 },
37
38 add: function(button) {
39 console.log('add');
40 var record = Ext.create('Lada.model.Messwert', {
41 messungsId: button.up('messwertgrid').recordId
42 });
43 button.up('messwertgrid').store.insert(0, record);
44 button.up('messwertgrid').rowEditing.startEdit(0, 1);
45 },
46
47 remove: function(button) {
48 var grid = button.up('grid');
49 var selection = grid.getView().getSelectionModel().getSelection()[0];
50 Ext.MessageBox.confirm('Messwert löschen', 'Sind Sie sicher?', function(btn) {
51 if (btn === 'yes') {
52 selection.destroy({
53 success: function() {
54 button.up('window').initData();
55 grid.initData();
56 },
57 failure: function() {
58 // TODO
59 }
60 });
61 }
62 });
63 }
64 });

http://lada.wald.intevation.org