mardi 16 juin 2015

How to get data out of an ember js class object

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.

I created a component on my view using {{kendo-ui.kendo-table descriptor=tableDescriptor data=model}}

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 a for larger model arrays. Is there a quick way to extract all the _data from my array of ember objects?




Aucun commentaire:

Enregistrer un commentaire