I'm fairly new to ember and I'd like to know whats the fastest way to extract the data out of ember objects. I've loaded my model with a very large amount of records using this.store.find('modelName);` in my route.
I created a component on my view using {{kendo-ui.kendo-table descriptor=tableDescriptor data=model}}. My controller defined other arguments to be passed to my component (descriptor).
In my components.js I'm' getting the data passed over by using
export default Ember.Component.extend({
didInsertElement: function() {
var columns = this.get('descriptor.columns'); // this is right
var model = this.get('data')['content']; // this returns the objects of the model
var height = this.get('descriptor.height'); // this is ok too
Ember.$('#kendo-table').kendoGrid({
dataSource: {
data: model,
pageSize: 100
},
height: height,
scrollable: {
virtual: true
},
groupable: true,
sortable: true,
columns: columns
});
}
});
On the line var model = this.get('data')['content'];, this gives me an Array of Ember Classes. Inside each class, there is a _data object that holds the value of the actual class.
The easiest solutions is to just loop through and extract the _data but that is no good for larger model array. Is there a quick way to extract all the _data from my array of ember objects?
this.get('data')- artychthis.get('data').get('data')since first level is referring to the array of classes and the second level is referring to... each object in the array? - lzcthis.store.find('modelName')is promise that resolved as RecordArray 2) you could get it in route controller asmodel3) you passmodelto component asdata=> 4) so my answer isthis.get('data')in component - artychthis.store.find('modelName'), it is binded to my controller. My controller has an attribute namedmodelI believe this includesthis.controllerand the model its binded to. I then pass themodelto my component. Now I need to get the data that came fromthis.store.find('modelName').get('data'), should I inject my component with thestoreas components don't come with it? - lzcperson(with 1 attrname). In routerthis.store.find('person')is promise. In controller it is already resolved as RecordArray, for example first element name:this.get('model').get('firstObject').get('name'). 2) you passmodelto component asdata=> my answer isthis.get('data')in component - artych