我想使用分页并且我做到了,但我没有得到我想要的那部分。我想通过一些解决方案,但仍然没有得到。
我在做什么是:
模型中的查询部分:
public static Page<User> page(int page, int pageSize, String sortBy, String order, String filter) {
return find.where()
.ilike("name", "%" + filter + "%")
.orderBy(sortBy + " " + order)
.findPagingList(pageSize)
.getPage(page);
}
查看部分:
@(currentPage: com.avaje.ebean.Page[User], currentSortBy: String, currentOrder: String, currentFilter: String,ud: String)
@****************************************
* Helper generating navigation links *
****************************************@
@link(newPage:Int, newSortBy:String) = @{
var sortBy = currentSortBy
var order = currentOrder
if(newSortBy != null) {
sortBy = newSortBy
if(currentSortBy == newSortBy) {
if(currentOrder == "asc") {
order = "desc"
} else {
order = "asc"
}
} else {
order = "asc"
}
}
// Generate the link
routes.paging.pag(newPage, sortBy, order, currentFilter)
}
@header(key:String, title:String) = {
<a class="@key.replace(".","_") header @if(currentSortBy == key) @{if(currentOrder == "asc") "headerSortDown" else "headerSortUp"}" href="@link(0,key)">@title</a>
}
@main("welcome to EXTR ") {
<div class="container-narrow">
<div class="masthead">
<ul class="nav nav-pills pull-right">
<li><a href="@routes.paging.extrad(ud)" >Extr resume</a></li>
<li><a href="@routes.signin.logou">Logout</a></li>
</ul>
<h3 class="muted">
welcome admin</b>
</h3>
</div>
<hr><div align="center">
<h1> @currentPage.getTotalRowCount() user found</h1>
@if(currentPage.getTotalRowCount == 0) {
<div class="well">
<em>Nothing to display</em>
</div>
} else {
<table border="1" >
<tr>
<th>@header("name","name")</th>
<th>@header("email","email")</th>
<th>@header("","")</th>
</tr>
<tbody>
@for(user <- currentPage.getList) {
<tr>
<td><a href="">@user.name</a></td>
<td>
@user.getEmail()
</td>
<td><a href="@routes.update.del(user.id)" class="btn success" style="color:#008000; ">delete</a></td>
</tr>}
</tbody>
</table>
<div id="pagination" class="pagination">
<ul>
@if(currentPage.hasPrev) {
<li class="prev">
<a href="@link(currentPage.getPageIndex - 1, null)">← Previous</a>
</li>
} else {
<li class="prev disabled">
<a>← Previous</a>
</li>
}
@for(i <- 0 until currentPage.getTotalPageCount()){
<li><a href="@link(i, null)">@(i+1)</a></li>
}
@if(currentPage.hasNext) {
<li class="next">
<a href="@link(currentPage.getPageIndex + 1, null)">Next →</a>
</li>
} else {
<li class="next disabled">
<a>Next →</a>
</li>
}
</ul>
</div>
}
</div>
</div>
}
我得到的是:
但我想要的是
一次我想显示到 5 页,当单击第 5 页时,它再次到达 5-10 页。但我的分页是一次获取所有页面。
我希望数字以这种格式显示..
1 2 3 4 5 ^
如果我按 5,那么它应该显示从 5 到 10
5 6 7 8 9 10
直到最大记录可用。我只想知道如何显示数字。
给我一些想法来做到这一点。