我想使用分页,我做了但我没有得到我想要的那部分。我想通过一些解决方案,但仍然没有得到。
我在做什么:
在模型中查询部分:
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
直到最大记录可用。我只是想知道如何显示数字。
给我一些想法。