ASP.NET MVC PaginatoredList 分页器 - 明智地说“...”在某一点之后
我已经为我的 ASP.NET MVC 项目创建了一个分页列表和分页器。效果很好,事情就是这样。
我无法弄清楚的一件事是如何在某个点之后放置 ...
。例如,假设我的寻呼机如下所示:
1
2
3
4
5 <代码>6 <代码>7 <代码>8 <代码>9 <代码>10 <代码>11
12
13
14
下一步>>
我需要的是如下内容:
1
2
3
4
5
6
7
8
9
10< /code>
...
下一步>>>
这里的 ...
是针对 11
的。当我们转到页面 11
时,寻呼机应如下所示:
...
11
12
13
14
Next >>>
这个实现是我不知道如何做到这一点的实现。
这是我当前的寻呼机代码的样子:
<div id="pager">
@if (Model.PrimaryModel.HasPreviousPage) {
@:@Html.ActionLink(
"<<< Previous",
Model.Property["action"],
new {
controller = Model.Property["controller"],
Area = Model.Property["area"],
page = (Model.PrimaryModel.PageIndex - 1)
},
new {
data_jquery_ajax_url = Url.Action(
string.Format("pagerAjaxCall_{0}", Model.Property["action"]),
new {
controller = Model.Property["controller"],
Area = Model.Property["area"],
page = (Model.PrimaryModel.PageIndex - 1)
}
)
}
)
}
@if (Model.PrimaryModel.TotalPages >= 2) {
int totalPageNumber = 0;
for (int i = 0; i < Model.PrimaryModel.TotalPages; i++) {
int value = i + 1;
if (Model.PrimaryModel.PageIndex == i) {
@:@Html.ActionLink(value.ToString(), Model.Property["action"], new { controller = Model.Property["controller"], Area = Model.Property["area"], page = (i) }, new { @class = "active-page", data_jquery_ajax_url = Url.Action(string.Format("pagerAjaxCall_{0}", Model.Property["action"]), new { controller = Model.Property["controller"], Area = Model.Property["area"], page = (i) }) })
} else {
@:@Html.ActionLink(value.ToString(), Model.Property["action"], new { controller = Model.Property["controller"], Area = Model.Property["area"], page = (i) }, new { data_jquery_ajax_url = Url.Action(string.Format("pagerAjaxCall_{0}", Model.Property["action"]), new { controller = Model.Property["controller"], Area = Model.Property["area"], page = (i) }) })
}
totalPageNumber++;
}
@*@:current : @(Model.PrimaryModel.PageIndex+1), totalPage @totalPageNumber.ToString(), right side @((totalPageNumber - Model.PrimaryModel.PageIndex)-1), left side @(totalPageNumber - (totalPageNumber - Model.PrimaryModel.PageIndex))*@
}
@if (Model.PrimaryModel.HasNextPage) {
@:@Html.ActionLink(
"Next >>>",
Model.Property["action"],
new {
controller = Model.Property["controller"],
Area = Model.Property["area"],
page = (Model.PrimaryModel.PageIndex + 1)
},
new {
data_jquery_ajax_url = Url.Action(
string.Format("pagerAjaxCall_{0}", Model.Property["action"]),
new {
controller = Model.Property["controller"],
Area = Model.Property["area"],
page = (Model.PrimaryModel.PageIndex + 1)
}
)
}
)
}
</div>
有什么想法吗?
I have created a paginatedList and pager for that for my ASP.NET MVC project. It works great, well thing so.
One thing that I cannot figure it out is to how to put ...
after certain point. For example, lets say my pager looks like as follows :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Next >>>
What I need is some thing as follows :
1
2
3
4
5
6
7
8
9
10
...
Next >>>
the ...
is for 11
here. When we go to page 11
, the pager should be as follows :
...
11
12
13
14
Next >>>
This implementation is the one which I cannot figure it out how to do this.
And here is how my current pager code looks like :
<div id="pager">
@if (Model.PrimaryModel.HasPreviousPage) {
@:@Html.ActionLink(
"<<< Previous",
Model.Property["action"],
new {
controller = Model.Property["controller"],
Area = Model.Property["area"],
page = (Model.PrimaryModel.PageIndex - 1)
},
new {
data_jquery_ajax_url = Url.Action(
string.Format("pagerAjaxCall_{0}", Model.Property["action"]),
new {
controller = Model.Property["controller"],
Area = Model.Property["area"],
page = (Model.PrimaryModel.PageIndex - 1)
}
)
}
)
}
@if (Model.PrimaryModel.TotalPages >= 2) {
int totalPageNumber = 0;
for (int i = 0; i < Model.PrimaryModel.TotalPages; i++) {
int value = i + 1;
if (Model.PrimaryModel.PageIndex == i) {
@:@Html.ActionLink(value.ToString(), Model.Property["action"], new { controller = Model.Property["controller"], Area = Model.Property["area"], page = (i) }, new { @class = "active-page", data_jquery_ajax_url = Url.Action(string.Format("pagerAjaxCall_{0}", Model.Property["action"]), new { controller = Model.Property["controller"], Area = Model.Property["area"], page = (i) }) })
} else {
@:@Html.ActionLink(value.ToString(), Model.Property["action"], new { controller = Model.Property["controller"], Area = Model.Property["area"], page = (i) }, new { data_jquery_ajax_url = Url.Action(string.Format("pagerAjaxCall_{0}", Model.Property["action"]), new { controller = Model.Property["controller"], Area = Model.Property["area"], page = (i) }) })
}
totalPageNumber++;
}
@*@:current : @(Model.PrimaryModel.PageIndex+1), totalPage @totalPageNumber.ToString(), right side @((totalPageNumber - Model.PrimaryModel.PageIndex)-1), left side @(totalPageNumber - (totalPageNumber - Model.PrimaryModel.PageIndex))*@
}
@if (Model.PrimaryModel.HasNextPage) {
@:@Html.ActionLink(
"Next >>>",
Model.Property["action"],
new {
controller = Model.Property["controller"],
Area = Model.Property["area"],
page = (Model.PrimaryModel.PageIndex + 1)
},
new {
data_jquery_ajax_url = Url.Action(
string.Format("pagerAjaxCall_{0}", Model.Property["action"]),
new {
controller = Model.Property["controller"],
Area = Model.Property["area"],
page = (Model.PrimaryModel.PageIndex + 1)
}
)
}
)
}
</div>
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是应该让您了解如何修复它
Just should give you a general idea of how to fix it