[Lada-commits] [PATCH 2 of 5] Implemented the 'add' button; fixed renderer and controller

Wald Commits scm-commit at wald.intevation.org
Tue Mar 10 14:32:12 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1425985910 -3600
# Node ID 1dedce48e3e1feee90ae63d1c0833767a68e0b61
# Parent  1f6a22107c8c13d7fcd4134c3b6431568e83d89e
Implemented the 'add' button; fixed renderer and controller.

diff -r 1f6a22107c8c -r 1dedce48e3e1 app/controller/ProbenzusatzwertGrid.js
--- 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
                     }
                 });
             }
diff -r 1f6a22107c8c -r 1dedce48e3e1 app/view/grid/Probenzusatzwert.js
--- 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');


More information about the Lada-commits mailing list