I want to build a table using ember 1.9 and ember data. This means that since I’m using handlebars 2.0, I can’t use Addepar/Ember-Table.
My initial design went something like this.
App.Source = DS.Model.extend({
name: DS.attr('string'),
primary: DS.attr('boolean'),
published: DS.attr('boolean'),
sort: DS.attr('number'),
summaryRows: DS.hasMany('summaryRow', {
async: true,
})
});
App.SummaryRow = DS.Model.extend({
locationId: DS.attr('string'),
locationName: DS.attr('string'),
cells: DS.hasMany('cell', {
async: true
}),
source: DS.belongsTo('source')
});
App.Cell = DS.Model.extend({
hexColor: DS.attr('string'),
name: DS.attr('string'),
optionId: DS.attr('number'),
options: DS.hasMany('option', {
async: true
}),
summaryRow: DS.belongsTo('summaryRow')
});
App.Option = DS.Model.extend({
name: DS.attr('string'),
hexColor: DS.attr('string'),
cell: DS.belongsTo('cell')
});
The issue with doing it this way, is its going to make a request for 50 summary rows, then each of those summary rows is going to make a request to get its values (so that’s 50 requests because I am using the links hash and not sending IDS, which also means I can’t sideload data). Then when they click on the value (individual cell) I want to open up a model that they can change which option is currently selected in that cell (or value).
What is the best way to make a table and model the table data with ember data?