changeset 571:1dedce48e3e1

Implemented the 'add' button; fixed renderer and controller.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 10 Mar 2015 12:11:50 +0100
parents 1f6a22107c8c
children 2c8aa09402a2
files app/controller/ProbenzusatzwertGrid.js app/view/grid/Probenzusatzwert.js
diffstat 2 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/app/controller/ProbenzusatzwertGrid.js	Tue Mar 10 12:09:50 2015 +0100
+++ b/app/controller/ProbenzusatzwertGrid.js	Tue Mar 10 12:11:50 2015 +0100
@@ -35,8 +35,12 @@
         });
     },
 
-    add: function() {
-        console.log('add');
+    add: function(button) {
+        var record = Ext.create('Lada.model.Zusatzwert', {
+            probeId: button.up('probenzusatzwertgrid').recordId
+        });
+        button.up('probenzusatzwertgrid').store.insert(0, record);
+        button.up('probenzusatzwertgrid').rowEditing.startEdit(0, 1);
     },
 
     remove: function(button) {
@@ -47,8 +51,10 @@
                 selection.destroy({
                     success: function() {
                         button.up('window').initData();
+                        grid.initData();
                     },
                     failure: function() {
+                        // TODO
                     }
                 });
             }
--- a/app/view/grid/Probenzusatzwert.js	Tue Mar 10 12:09:50 2015 +0100
+++ b/app/view/grid/Probenzusatzwert.js	Tue Mar 10 12:11:50 2015 +0100
@@ -27,11 +27,11 @@
     recordId: null,
 
     initComponent: function() {
-        var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
+        this.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
             clicksToMoveEditor: 1,
             autoCancel: false
         });
-        this.plugins = [rowEditing];
+        this.plugins = [this.rowEditing];
         this.dockedItems = [{
             xtype: 'toolbar',
             dock: 'bottom',
@@ -55,6 +55,9 @@
             dataIndex: 'pzsId',
             flex: 1,
             renderer: function(value) {
+                if (!value || value === '') {
+                    return '';
+                }
                 var store = Ext.data.StoreManager.get('probenzusaetze');
                 var record = store.getById(value);
                 return record.get('beschreibung');
@@ -85,6 +88,9 @@
             dataIndex: 'pzsId',
             width: 80,
             renderer: function(value) {
+                if (!value || value === '') {
+                    return '';
+                }
                 var zstore = Ext.data.StoreManager.get('probenzusaetze');
                 var mstore = Ext.data.StoreManager.get('messeinheiten');
                 var mehId = zstore.getById(value).get('mehId');

http://lada.wald.intevation.org