I'm looking for a good way to bind grouped objects and render it to the grid. Here's a grid example:
| League / Country | Canada | United States | Brazil |
| 1 | John, Sam | | Tim |
| 2 | Liam | | Robert |
| 3 | | James, Peter, Tom | Den |
And Player's model
DS.Model.extend({
name: DS.attr(),
country: DS.attr(),
leagueId: DS.attr("number")
});
And data received from backend is:
[
{ name: "John", country: "Canada", leagueId: 1 },
{ name: "Sam", country: "Canada", leagueId: 1 },
{ name: "Tim", country: "Brazil", leagueId: 1 },
{ name: "Liam", country: "Canada", leagueId: 2 },
...
]
I thought about having something following:
{{#each country in countries}}
<tr>
{{#each league in leagues}}
<td>
{{#each player in players}}
{{#is player.country "==" country}}
{{#is player.leagueId "==" league}}
... output player ..., e.g. {{ render 'player/card' player }}
{{/is}}
{{/is}}
{{/each}}
</td>
{{/each}}
</tr>
{{/each}}
But having filtering within template does not look good. Is there a good way to move it to controller?
What is the Ember-way to output list of players into such grid, so that it nicely bound and if I change country or league - player is rendered into proper cell?