I am looking for a good way to snap grouped objects and display them in a grid. Here is an example of a grid:
| League / Country | Canada | United States | Brazil | | 1 | John, Sam | | Tim | | 2 | Liam | | Robert | | 3 | | James, Peter, Tom | Den |
And the player model
DS.Model.extend({ name: DS.attr(), country: DS.attr(), leagueId: DS.attr("number") });
And the data obtained from the backend:
[ { 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 of the 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 ..., eg {{ render 'player/card' player }} {{/is}} {{/is}} {{/each}} </td> {{/each}} </tr> {{/each}}
But filtering inside the template does not look very good. Is there any way to move it to the controller?
What is the Ember-way for displaying the list of players in such a grid so that it is well attached, and if I change the country or player of the league, it is displayed in the correct cell?