문제

I'm working on this playframework project. I have a list of ploegen and each ploeg has its punten. punten is an integer. I want to sort them by the value of punten. How can I do that?

This is the list I have now, it shows the plogen in the order they are stored in the database:

 <ul>
    @for(ploeg <- ploegen) {
        <li>
            @ploeg.naam
            @ploeg.punten
            @form(routes.Application.deletePloeg(ploeg.id)) {
                <input type="submit" value="Delete">
            }

        </li>
    }
</ul>
도움이 되었습니까?

해결책

As Robin said you should sort elements in backend. You can do it like this:

Finder<Long, Ploeg> find = new Finder<Long, Ploeg>(Long.class, Ploeg.class);
List<Ploeg> ploegen = find.orderBy("punten asc").findList();

다른 팁

First, sorting should be done in the controller, in the code that accesses the database. You can use an EBean filter. That will sort in memory. I'm not familiar with Ebean so I don't know if there is a better way.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top