Ok, so it sounds like you have something like this?
var MyView = Ember.View.extend({
columnsData: [this.columnData1, this.columnData2],
columnData1: [ {"name" : "John"}, {"name": "Tony"} ],
columnData2: [ {"name": "Sara"}, {"name": "Amanda"} ]
})
If so, the reason this isn’t working is because when columnsData is set, this does not refer to the view. There are a few ways you could fix this. One is to set it up in init:
var MyView = Ember.View.extend({
// Note, setting these to null isn't actually
// necessary—I just like it so I know what data
// there is
columnsData: null,
columnData1: null,
columnData2: null,
init: function() {
this._super();
this.set('columnData1', [ {"name" : "John"}, {"name": "Tony"} ]);
this.set('columnData2', [ {"name": "Sara"}, {"name": "Amanda"} ]);
this.set('columnsData', [this.get('columnData1'), this.get('columnData2')])
}
})
What happens here is when the view is created, it runs init and then sets all the appropriate properties. Since init is run in the context of the view instance, you can refer to other properties in it. Also, you might notice I set up columnData1 and columnData2 in init as well. Check out this blog post under “Initialization (and a common mistake!)” for info on why that’s a good idea.
Another way to do this is with computed properties:
var MyView = Ember.View.extend({
columnData1: null,
columnData2: null,
init: function() {
this._super();
this.set('columnData1', [ {"name" : "John"}, {"name": "Tony"} ]);
this.set('columnData2', [ {"name": "Sara"}, {"name": "Amanda"} ]);
},
columnsData: function() {
return [this.get('columnData1'), this.get('columnData2')]
}.property('columnData1.[]', 'columnData2.[]')
})
Now, whenever columnData1 or columnData2 changes, columnsData is automatically updated.
Also important to note: you should be using get and set for accessing values on your objects—this allows a lot of the Ember magic to take place (like computed properties).