I have two models and one view, but can not find the proper way how to combine/join
the models.
Both Sproutcore models (Employee data) have an attribute function description
. But the currently used model function description
is out of date, so I need to use the function description
of the other model.
functieLabel: function(){
var bsnInt = parseInt(this.get('bsn'));
if (SC.none(bsnInt)) return 'loading...';
//var query = SC.Query.local(App.Medewerker, { conditions: 'bsn = bsnParam'}, {parameters: bsnParam = bsnInt});
var query = SC.Query.local(App.Medewerker, { conditions: 'bsn = %{bsnParam}'}, {parameters: { bsnParam: bsnInt } });
var results = App.store.find(query);
SC.info('results: length=%@', results.length());
SC.info('functie: functie=%@',results.objectAt(0).get("functie"))
var functie = results.objectAt(0).get("functie");
return functie
}.property('functieLabel'),
I extended MedewerkerDetailInfo with a computed property functieLabel. But the query is not correct, that is, all records are return. Suggestions? Thanks in advance.
App.MedewerkerDetailInfo = SC.Record.extend({
..
functieLabel: function() {
..
}.property('functieLabel'),
..
App.Medewerker = SC.Record.extend({
..
functie: SC.Record.attr
This one is working as expected:
functieLabel: function(){
var bsnInt = parseInt(this.get('bsn'));
if (SC.none(bsnInt)) return 'loading...';
var query = SC.Query.local(App.Medewerker, {conditions: "bsn = %@", parameters: [bsnInt]});
var results = Sea.store.find(query);
var lengte = results.length()
if (lengte = 0){
return "onbepaald".toString()
}
else {
return results.getEach("functie").toString()
}
}.property('bsn'),