changeset 123:d78bb4ca6089

Enabled accessing nested data in the grid through a renderer.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 21 Jun 2013 17:41:16 +0200
parents a7bfaeb1655d
children 1907f405eb93
files app/model/Zusatzwert.js app/view/zusatzwerte/List.js
diffstat 2 files changed, 30 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/app/model/Zusatzwert.js	Fri Jun 21 16:56:17 2013 +0200
+++ b/app/model/Zusatzwert.js	Fri Jun 21 17:41:16 2013 +0200
@@ -10,14 +10,15 @@
         {name: "nwgZuMesswert", type: 'float'},
         {name: "messwertPzs", type: 'float'},
         {name: "messfehler", type: 'float'},
-        {name: "letzteAenderung", type: 'date', convert: ts2date, defaultValue: new Date()}
+        {name: "letzteAenderung", type: 'date', convert: ts2date, defaultValue: new Date()},
 
-        //// This are fields from the s_zusatzwert_table. They are currently not
-        //// needed for displaying values in the grid.
-        //{name: "sprobenZusatz"},
-        //{name: "sprobenZusatz_beschreibung", mapping: "sprobenZusatz.beschreibung"},
-        //{name: "sprobenZusatz_pzsId", mapping: "sprobenZusatz.pzsId"},
-        //{name: "sprobenZusatz_mehId", mapping: "sprobenZusatz.mehId"}
+        // Field for the nested Probenzusatzobject. This one is needed to have
+        // access to the nested data in the grid.
+        // TODO: I would have expected that this field does not need to be
+        // defined explicitly as there is the hasOne asscociation defined
+        // which name and associationKey named "sprobenZusatz". Anyway it does
+        // not seem to make problems.
+        {name: "sprobenZusatz"}
     ],
     hasOne: [
         {
--- a/app/view/zusatzwerte/List.js	Fri Jun 21 16:56:17 2013 +0200
+++ b/app/view/zusatzwerte/List.js	Fri Jun 21 17:41:16 2013 +0200
@@ -30,11 +30,30 @@
             }
         ];
         this.columns = [
-            {header: 'PZW-ID', dataIndex: 'sprobenZusatz_pzsId'},
-            {header: 'PZW-Größe', dataIndex: 'sprobenZusatz_beschreibung', flex: 1},
+            {
+                header: 'PZW-ID',
+                dataIndex: 'sprobenZusatz',
+                renderer: function(value) {
+                    return value.pzsId;
+                }
+            },
+            {
+                header: 'PZW-Größe',
+                dataIndex: 'sprobenZusatz',
+                renderer: function(value) {
+                    return value.beschreibung;
+                },
+                flex: 1
+            },
             {header: 'Messwert', dataIndex: 'messwertPzs'},
             {header: 'rel. Unsich.[%]', dataIndex: 'messfehler'},
-            {header: 'Maßeinheit', dataIndex: 'sprobenZusatz_mehId'}
+            {
+                header: 'Maßeinheit',
+                dataIndex: 'sprobenZusatz',
+                renderer: function(value) {
+                    return value.mehId;
+                }
+            }
         ];
         this.callParent(arguments);
     }

http://lada.wald.intevation.org