jQuery Pagination Paging Plug in Explanation

  • 2021-07-24 09:45:51
  • OfStack

This article example for everyone to share the jQuery Pagination paging plug-in specific code, for your reference, the specific content is as follows

1. Reference to CSS and JS:


<link href="/Content/Plugins/jQuery.Pagination_v2.2/pagination.css" rel="external nofollow" rel="stylesheet"
 type="text/css" />
<script src="/Content/Plugins/jQuery.Pagination_v2.2/jquery.pagination.js" type="text/javascript"></script>

2. HTML:


<div id="Pagination" class="flickr" style="margin-top: 10px; margin-left: 10px;">
</div>

3. JS:


$(function () {
 var total = parseInt("@(ViewBag.total)");
 var page = parseInt("@(ViewBag.page)") - 1;
 var pageSize = parseInt("@(ViewBag.pageSize)");

 $("#Pagination").pagination(total, {
 callback: function (page_id) {
  window.location = "BoardList?page=" + page_id + "&pageSize=" + this.items_per_page;
 }, //PageCallback()  Call the secondary function for page turning. 
 prev_text: "  Upper 1 Page ",
 next_text: " Under 1 Page  ",
 items_per_page: 10, // Number of data per page 
 num_display_entries: 1, // Number of end-to-end paging entries on both sides 
 current_page: page, // Current page number 
 num_edge_entries: 11 // Number of paging entries in the main part of continuous paging 
 });
});

4. Background code:


public ActionResult BoardList()
{
 PagerModel pager = new PagerModel();
 if (Request["page"] == null)
 {
 pager.page = 1;
 pager.rows = 10;
 pager.sort = "Id";
 pager.order = "desc";
 }
 else
 {
 pager.page = int.Parse(Request["page"]) + 1;
 pager.rows = int.Parse(Request["pageSize"]);
 pager.sort = "Id";
 pager.order = "desc";
 }

 boardManageService.GetList(ref pager);
 List<BoardModel> boardList = pager.result as List<BoardModel>;
 ViewData["BoardModelList"] = boardList;
 ViewBag.page = pager.page;
 ViewBag.total = pager.totalRows;
 ViewBag.pageSize = pager.rows;

 return View();
}
#endregion

For more exciting content, please click: jquery paging function summary to learn.


Related articles: