Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/plantain-00/bootstrap.pagination
a Bootstrap pagination and pager for asp.net MVC and Webform
https://github.com/plantain-00/bootstrap.pagination
Last synced: 12 days ago
JSON representation
a Bootstrap pagination and pager for asp.net MVC and Webform
- Host: GitHub
- URL: https://github.com/plantain-00/bootstrap.pagination
- Owner: plantain-00
- License: mit
- Created: 2014-06-25T01:40:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-22T13:57:00.000Z (over 9 years ago)
- Last Synced: 2024-05-29T09:23:00.728Z (5 months ago)
- Language: C#
- Homepage:
- Size: 1.94 MB
- Stars: 7
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Bootstrap.Pagination
====================Get Started
--------------------### HomeController
private readonly int[] _list;
public HomeController()
{
_list = new int[123];
for (var i = 0; i < 123; i++)
{
_list[i] = i + 1;
}
}public ActionResult Index(int page = 1)
{
var skipped = Pagination.GetSkipped(page);
ViewData["pagination"] = new Pagination(_list.Length, page);
ViewData["data"] = _list.Skip(skipped).Take(10).ToArray();
return View();
}public ActionResult List(int page = 1)
{
var skipped = Pagination.GetSkipped(page);
ViewData["pagination"] = new Pagination(_list.Length, page);
ViewData["data"] = _list.Skip(skipped).Take(10).ToArray();
return View();
}### Index View
@Html.Partial("List")
function navigateTo(page) {
$.ajax({
url : "@Url.Action("List")",
data : {
page : page
},
success : function(data) {
$("#list").html(data);
}
});
}
### List View
@{
var data = ViewData["data"] as int[];
}
- @d
@foreach (var d in data)
{
}
@Html.Partial("Pagination")
example for pagination
--------------------
### Controller
public ActionResult Index(int page = 1)
{
var skipped = Pagination.GetSkipped(page);
ViewData["pagination"] = new Pagination(123, page);
ViewData["data"] = _list.Skip(skipped).Take(10).ToArray();
return View();
}
public ActionResult GetPagination(int page = 1)
{
var skipped = Pagination.GetSkipped(page);
ViewData["pagination"] = new Pagination(123, page);
ViewData["data"] = _list.Skip(skipped).Take(10).ToArray();
return this.NewtonJson(new
{
pagination = this.PartialViewToString("Pagination"),
data = this.PartialViewToString("DataList")
},
JsonRequestBehavior.AllowGet);
}
### View
@Html.Partial("DataList")
@Html.Partial("Pagination")
function navigateTo(page, group) {
$.getJSON("@Url.Action("GetPagination")", {
page : page
}, function(json) {
$("#pagination").html(json.pagination);
$("#data").html(json.data);
});
}
![](https://raw.githubusercontent.com/plantain-00/Bootstrap.Pagination/master/images/Pagination-Example.JPG)
example for pager
--------------------
### Controller
public ActionResult PagerIndex(int page = 1)
{
var skipped = Pager.GetSkipped(page);
ViewData["pager"] = new Pager(123, page);
ViewData["data"] = _list.Skip(skipped).Take(10).ToArray();
return View();
}
public ActionResult GetPager(int page = 1)
{
var skipped = Pager.GetSkipped(page);
ViewData["pager"] = new Pager(123, page);
ViewData["data"] = _list.Skip(skipped).Take(10).ToArray();
return this.NewtonJson(new
{
pager = this.PartialViewToString("Pager"),
data = this.PartialViewToString("DataList")
},
JsonRequestBehavior.AllowGet);
}
### View
@Html.Partial("DataList")
@Html.Partial("Pager")
function navigateTo(page) {
$.getJSON("@Url.Action("GetPager")", {
page : page
}, function(json) {
$("#pager").html(json.pager);
$("#data").html(json.data);
});
}
![](https://raw.githubusercontent.com/plantain-00/Bootstrap.Pagination/master/images/Pager-Example.JPG)
## nuget
You can get [it](https://www.nuget.org/packages/Bootstrap.Pagination) and [MVC](https://www.nuget.org/packages/Bootstrap.Pagination.MVC/) from Nuget.