0
how to display data table items in the reverse order in order of id ...

back language i'am using scala 

reverse order  data in the data table or models,and display on  in view the page using,
play framework or Normal html

表示ページで...

@helper.form(action = routes.Application.listAllpost) {
<fieldset>
@for(post<- posts){
<h3>
@post.name </h3><br/><br/>
</fieldset>
}

および投稿をリストするアプリケーションページで

val pos:Post=null
val postNotifiaction:PostNotification=null
def listAllpost()= Action{

    val post:List[Post]=Post.listAllPostById
    Ok(views.html.allPosts.render(Application.postNotificationForm,post,pos,postNotifiaction))
      }

def listPsts = Action { implicit request =>
        val today = Calendar.getInstance().getTime()
        val alert: Alert = new Alert("", "")
        Common.setAlert(alert)
        createPostForm.bindFromRequest.fold(
        errors => BadRequest(views.html.createPost(errors, "There is some error","")),
    post => {
        Post.findByPostName(post.name).isEmpty match {
    case true =>  case false =>
        }
        Results.Redirect("/post")
       })
    }

ここでは、最後のページをリロードするときに、db に apost を追加します。

だから私は最後の投稿が一番上にあったことを望みます..方法はあります..誰もが方法を知っています..ここに言及してください....

4

1 に答える 1

3

List.reverseIterator()「逆順で要素を生成するイテレータ」を返す場合、次を使用して投稿を逆順でリストできます

@for(post <- posts.reverseIterator()) {
    @post.name<br>
}
于 2013-06-07T08:18:45.293 に答える