comparison app/controller/grid/Status.js @ 594:89b337cbfb5d

Added status grid and controller.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 12 Mar 2015 09:46:17 +0100
parents
children 8acb3123b46c
comparison
equal deleted inserted replaced
593:9b3adfb7b1ae 594:89b337cbfb5d
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.Status', {
10 extend: 'Ext.app.Controller',
11
12 init: function() {
13 this.control({
14 'statusgrid': {
15 edit: this.gridSave
16 },
17 'statusgrid button[action=add]': {
18 click: this.add
19 },
20 'statusgrid 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.initData();
30 context.grid.up('window').initData();
31 },
32 failure: function() {
33 // TODO
34 }
35 });
36 },
37
38 add: function(button) {
39 var record = Ext.create('Lada.model.Status', {
40 messungsId: button.up('statusgrid').recordId
41 });
42 button.up('statusgrid').store.insert(0, record);
43 button.up('statusgrid').rowEditing.startEdit(0, 1);
44 },
45
46 remove: function(button) {
47 var grid = button.up('grid');
48 var selection = grid.getView().getSelectionModel().getSelection()[0];
49 Ext.MessageBox.confirm('Messwert löschen', 'Sind Sie sicher?', function(btn) {
50 if (btn === 'yes') {
51 selection.destroy({
52 success: function() {
53 button.up('window').initData();
54 grid.initData();
55 },
56 failure: function() {
57 // TODO
58 }
59 });
60 }
61 });
62 }
63 });

http://lada.wald.intevation.org