torsten@106: Ext.define('Lada.model.Zusatzwert', { torsten@106: extend: 'Ext.data.Model', torsten@122: requires: [ torsten@122: 'Lada.model.Probenzusatzwert' torsten@122: ], torsten@106: fields: [ torsten@106: {name: "id"}, torsten@127: // Commented out as pzsId must not be submitted to the server. On torsten@127: // serverside the pzsId is taken from the nested sprobenZusatz object. torsten@127: //{name: "pzsId", mapping: "id.pzsId"}, torsten@122: {name: "probeId", mapping: "id.probeId"}, torsten@114: {name: "nwgZuMesswert", type: 'float'}, torsten@114: {name: "messwertPzs", type: 'float'}, torsten@114: {name: "messfehler", type: 'float'}, torsten@123: {name: "letzteAenderung", type: 'date', convert: ts2date, defaultValue: new Date()}, torsten@114: torsten@123: // Field for the nested Probenzusatzobject. This one is needed to have torsten@123: // access to the nested data in the grid. torsten@123: // TODO: I would have expected that this field does not need to be torsten@123: // defined explicitly as there is the hasOne asscociation defined torsten@123: // which name and associationKey named "sprobenZusatz". Anyway it does torsten@123: // not seem to make problems. torsten@123: {name: "sprobenZusatz"} torsten@106: ], torsten@122: hasOne: [ torsten@122: { torsten@122: model: 'Lada.model.Probenzusatzwert', torsten@122: primaryKey: 'pzsId', torsten@122: name: 'sprobenZusatz', torsten@122: associationKey: 'sprobenZusatz', torsten@122: foreignKey: 'pzsId', torsten@122: getterName: 'getProbenzusatz', torsten@122: setterName: 'setProbenzusatz' torsten@122: } torsten@122: ], torsten@114: idProperty: "id", torsten@106: proxy: { torsten@106: type: 'rest', torsten@106: appendId: true, //default torsten@106: url: 'server/rest/zusatzwert', torsten@106: reader: { torsten@106: type: 'json', torsten@106: root: 'data' torsten@122: }, torsten@122: writer: { torsten@122: type: 'json', torsten@122: writeEverything : true torsten@106: } torsten@131: }, torsten@131: getEidi: function () { torsten@131: var sprobenZusatz = this.get('sprobenZusatz'); torsten@131: var pzsId = sprobenZusatz.pzsId; torsten@131: var probeId = this.get('probeId'); torsten@131: return "/" + pzsId + "/" + probeId; torsten@106: } torsten@106: }); torsten@106: torsten@106: function buildId(v, record){ torsten@114: return record.get('probeId') + ',' + record.get('pzsId'); torsten@106: } torsten@114: torsten@114: function ts2date(v, record){ torsten@114: // Converts a timestamp into a date object. torsten@114: return new Date(v); torsten@114: }