Mercurial > lada > lada-client
diff app/view/grid/Messung.js @ 945:023e622f9551
Added the ability to work with "StatusWerten" which are delivered by the lada-server.
To enable the uses of StatusWerte, the controller for the status grid, needed to be extended.
In addition, the form and grid views of Messung and Status were updated.
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Tue, 27 Oct 2015 16:46:58 +0100 |
parents | 07dfcdf5b41f |
children | c7bf0b459074 |
line wrap: on
line diff
--- a/app/view/grid/Messung.js Fri Oct 16 08:15:36 2015 +0200 +++ b/app/view/grid/Messung.js Tue Oct 27 16:46:58 2015 +0100 @@ -83,9 +83,10 @@ flex: 1, dataIndex: 'id', renderer: function(value) { - var id = 'messung-status-item' + value; - this.updateStatus(value, id); - return '<div id="' + id + '">Lade...</div>'; + var statusId = this.store.getById(value).get('status'); + var divId = 'messung-status-item' + value; + this.updateStatus(value, divId, statusId); + return '<div id="' + divId + '">Lade...</div>'; } }, { header: 'OK-Flag', @@ -147,12 +148,16 @@ }); }, - updateStatus: function(value, divId) { + /** + * Load the statusstore, + * afterwards: retrieve the statusid + */ + updateStatus: function(value, divId, statusId) { var statusStore = Ext.create('Lada.store.Status'); statusStore.on('load', this.updateStatusColumn, this, - {divId: divId}); + {divId: divId, statusId: statusId}); statusStore.load({ params: { messungsId: value @@ -197,18 +202,36 @@ Ext.fly(opts.divId).update(value); }, + /** + * Retrieve Statuswert and update the column + */ updateStatusColumn: function(sstore, record, success, opts) { - var value; + var value = 0; if (sstore.getTotalCount() === 0) { value = 0; } else { - value = sstore.last().get('status'); + value = sstore.getById(opts.statusId).get('statusWert'); } if (Ext.fly(opts.divId)) { - var sta = Ext.create('Lada.store.StatusWerte'); - var val = sta.getById(value).get('display'); - Ext.fly(opts.divId).update(val); + var sta = Ext.StoreManager.lookup('StatusWerte'); + if (!sta) { + var sta = Ext.create('Lada.store.StatusWerte'); + } + var val = 'error'; + sta.load({ + scope: this, + callback: function(records, operation, success) { + if (success) { + try { + val = sta.getById(value).get('wert'); + } + catch (e) { + } + } + Ext.fly(opts.divId).update(val); + } + }); } },