javascript - Ember group binding -


I'm looking for a great way to bind the grouped objects and to render them in the grid. Here's an example of a grid:

  | League / country Canada | United States Brazil | | 1 | John, Sam | | Tim | | 2 | Liam | | Robert | | 3 | | James, Peter, Tom | Dan |  

and model of the player

  dsmold.endend ({name: ds.T.TT.), country: ds. Rt () League ID: DS .attr ("number")});  

and data from the backend is:

  [[Name: "John", Country: "Canada", League ID: 1}, {name Country: "Canada", LeagueID: 1}, {Name: "Tim", Country: "Brazil", LeagueID: 1}, {name: "Liam", Country: "Canada", LeagueID: 2}, .. .]  

I thought about the following:

  {{every country in countries}} & lt; Tr & gt; {{# League in Leagues}} & lt; Td> {{Player in player]}} {{player # player player "country" == "country}} {{player.leagueId" == "league}} ... output player ..., e.g., {{render 'Player / card' player}} {{}} {{}} {{every}} & lt; / td & gt; {{/ each}}  {{ }}  

But filtering within the template does not look good. Is this a good way to move the controller?

The output list of players in such a grid The Amber way is so that it is good To be bound and if I change the country or league - the player is sung to the right question?

Note After your question:

Is there any way [block bound] in the form of a block? So that it is possible to: {{#filterByCountryAndLeague ...}} {{render 'player' Cord 'player}}

The answer is yes and no, see the docs as a bound helper

the bound helper handlar block or any way Do not support use with hair sequences.

But. .. If you need to use a template to display information for each player, you can use a component instead of a helper helper.

  App.FilteredPlayersComponent = Ember.Component.extend ({AllPlayers: Country for blank, forLeague: blank, filtered player: function () {var all players = this.jet ( 'All players'); var for country = this.get ('forcountry'); var forLeague = this.get 'ForLeague'); Var match = allPlayers.filterBy (for country, "country"). Filter ('LeagueID', for Leleg); Return matching;} .property ('all players. @ Every country', 'country for', 'league')});  

Then, inside your component template, you can temporarily render for each player:

  



    

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -