Mercurial > lada > lada-client
changeset 1032:fa04558f35cd
Load messung grid columns as record fields to get rid of 'Ext.fly'
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 18 Feb 2016 11:16:55 +0100 |
parents | 488fed1d2b98 |
children | e4b6b6c5fb89 |
files | app/model/Messung.js app/view/grid/Messung.js |
diffstat | 2 files changed, 49 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/app/model/Messung.js Wed Feb 17 14:25:40 2016 +0100 +++ b/app/model/Messung.js Thu Feb 18 11:16:55 2016 +0100 @@ -76,6 +76,15 @@ } return value; } + }, { + name: 'statusWert', + persist: false + }, { + name: 'messwerteCount', + persist: false + }, { + name: 'kommentarCount', + persist: false }], idProperty: 'id',
--- a/app/view/grid/Messung.js Wed Feb 17 14:25:40 2016 +0100 +++ b/app/view/grid/Messung.js Thu Feb 18 11:16:55 2016 +0100 @@ -81,15 +81,19 @@ }, { header: 'Status', flex: 1, - dataIndex: 'id', - renderer: function(value) { - var statusId = this.store.getById(value).get('status'); - var divId = 'messung-status-item' + value; + dataIndex: 'statusWert', + renderer: function(value, meta, record, rNdx, cNdx) { + var statusId = record.get('status'); + var mId = record.get('id'); //also fwd the record to the asynchronous loading of statuswerte // in order to add the statuswert to the record, // after the grid was rendered... - this.updateStatus(value, divId, statusId, this.store.getById(value)); - return '<div id="' + divId + '">Lade...</div>'; + if (value === '') { + this.updateStatus(mId, statusId, record); + return 'Lade...'; + } + var sta = Ext.data.StoreManager.getByKey('statuswerte'); + return sta.getById(value).get('wert'); } }, { header: 'OK-Flag', @@ -110,21 +114,27 @@ // Gibt die Anzahl der Messwerte wieder, // NICHT die Anzahl der verschiedenen Nukleide // Eventuell ist die Bezeichnug daher irreführend - dataIndex: 'id', + dataIndex: 'messwerteCount', flex: 1, - renderer: function(value) { - var id = 'messung-nuklid-item' + value; - this.updateNuklide(value, id); - return '<div id="' + id + '">Lade...</div>'; + renderer: function(value, meta, record) { + if (value === '') { + var mId = record.get('id'); + this.updateNuklide(mId, record); + return 'Lade...'; + } + return value; } }, { header: 'Anzahl Kommentare', flex: 1, - dataIndex: 'id', - renderer: function(value) { - var id = 'messung-kommentar-item' + value; - this.updateKommentare(value, id); - return '<div id="' + id + '">Lade...</div>'; + dataIndex: 'kommentarCount', + renderer: function(value, meta, record) { + if (value === '') { + var mId = record.get('id'); + this.updateKommentare(mId, record); + return 'Lade...'; + } + return value; } }]; this.listeners = { @@ -160,12 +170,12 @@ * Load the statusstore, * afterwards: retrieve the statusid */ - updateStatus: function(value, divId, statusId, record) { + updateStatus: function(value, statusId, record) { var statusStore = Ext.create('Lada.store.Status'); statusStore.on('load', this.updateStatusColumn, this, - {divId: divId, statusId: statusId, record: record}); + {statusId: statusId, record: record}); statusStore.load({ params: { messungsId: value @@ -173,28 +183,28 @@ }); }, - updateNuklide: function(value, divId) { + updateNuklide: function(id, record) { var messwerte = Ext.create('Lada.store.Messwerte'); messwerte.on('load', this.updateColumn, this, - {divId: divId}); + {record: record, type: 'messwerteCount'}); messwerte.load({ params: { - messungsId: value + messungsId: id } }); }, - updateKommentare: function(value, divId) { + updateKommentare: function(id, record) { var kommentare = Ext.create('Lada.store.MKommentare'); kommentare.on('load', this.updateColumn, this, - {divId: divId}); + {record: record, type: 'kommentarCount'}); kommentare.load({ params: { - messungsId: value + messungsId: id } }); }, @@ -212,7 +222,9 @@ else { value = 'k.A.'; } - Ext.fly(opts.divId).update(value); + opts.record.beginEdit(); + opts.record.set(opts.type, value); + opts.record.endEdit(); }, /** @@ -230,37 +242,9 @@ //add the determined statuswert to the record. // this is necessary to let the controller determine // which actions are allowed. - opts.record.data.statusWert = value; - } - } - if (Ext.fly(opts.divId)) { - //Try to get the statuswerte store, - // If it does not exist, create a new one. - var sta = Ext.data.StoreManager.getByKey('statuswerte'); - var val = 'error'; - if (!sta) { - // Set the Data asynchronously - sta = Ext.create('Lada.store.StatusWerte'); - sta.load({ - scope: this, - callback: function(records, operation, success) { - if (success) { - var item = sta.getById(value); - if (item) { - val = item.get('wert'); - } - } - Ext.fly(opts.divId).update(val); - } - }); - } - else { - // set the data - var item = sta.getById(value); - if (item) { - val = item.get('wert'); - } - Ext.fly(opts.divId).update(val); + opts.record.beginEdit(); + opts.record.set('statusWert', value); + opts.record.endEdit(); } } },