Also, I have one more file Pager.cs as follows to return nodes.
public static class Pager { public static DynamicNodeList Paged(this DynamicNodeList nodes, int page, int pageSize) { return new DynamicNodeList(nodes.Items.Skip((page - 1) * pageSize).Take(pageSize)); }
}
So, can anyone tell now how to implement the same?
if (totalPages > 1) { int cur_page = currentPage - 1; //finding the first linkbutton to be shown in the current display int start = cur_page - (cur_page % ButtonsCount);
//finding the last linkbutton to be shown in the current display int end = cur_page + (ButtonsCount - (cur_page % ButtonsCount));
if (currentPage-1 > 0) { //specify the position of prev button changed to -1
int prev_p = currentPage - 1;
link = GlobalRazorHelpers.AddOrReplaceParam(url, "page", prev_p.ToString());
<a class="pager-btn" href="@link">Prev</a>
}
if (start > ButtonsCount - 1) {
int dot = start - 1; link = GlobalRazorHelpers.AddOrReplaceParam(url, "page", dot.ToString()); <a class="pager-btn" href="@link">...</a>
}
int i = 0, j = 0,page=0;
for (i = start; i < end; i++) {
if (i < totalPages) { if (i+1 == currentPage) { page = i + 1; link = GlobalRazorHelpers.AddOrReplaceParam(url, "page", page.ToString()); <a class="pager-btn current-pager-btn" href="@link">@page</a> } else { page = i + 1; link = GlobalRazorHelpers.AddOrReplaceParam(url, "page", page.ToString()); <a class="pager-btn" href="@link">@page</a>
} } j++; }
if (totalPages > end) {
int dot2 = i + 1; link = GlobalRazorHelpers.AddOrReplaceParam(url, "page", dot2.ToString());
<a class="pager-btn" href="@link">...</a>
}
//condition added to keep the next button till the click of last button if (currentPage < totalPages) { int next_p = currentPage + 1;
link = GlobalRazorHelpers.AddOrReplaceParam(url, "page", next_p.ToString());
paging enhancement needed
Hello
I have PagerHelper class created as follows which will show prev, next buttons and in between all page buttons.
e.g. Prev - 1 - 2 -3 - 4 - 5 - 6 -7 - Next
But I now need some thing like ... Prev - 1 - 2 -3 - ... - Next
On clicking "..." it should show next 3 numbers say for e.g. Prev - 4 - 5 - 6 - ... - Next
My current code is as follows....
Also, I have one more file Pager.cs as follows to return nodes.
So, can anyone tell now how to implement the same?
like?
var skipPage = currentPage + 3;
for (int p = currentPage; p <= totalPages && p < skipPage; p++)
{
//string selected =(p == currentPage)?"selected":String.Empty;
link =GlobalRazorHelpers.AddOrReplaceParam(url,"page", p.ToString());
if(p == currentPage)
{
//<li>
<a class="pager-btn current-pager-btn" href="@link" title="Go to page @p of results">@p</a>
//</li>
}
else
{
//<li>
<a class="pager-btn" href="@link" title="Go to page @p of results">@p</a>
//</li>
}
}
@if (skipPage <= totalPages)
{
<a class="pager-btn" href="@Model.Url?page=@skipPage" title="">...</a>
}
Thank you for the response. It was helpful. But I made few changes and finally following code works fine for me.
is working on a reply...