从后台获取到的数据用jquery 如何进行分页呢??我从后台获取到的数据放在一个listView
我如何对这个页面进行分页呢??
http://www.cnblogs.com/yangtongnet/archive/2009/05/12/1455036.html
<script type="text/javascript" language="javascript">
var page=document.getElementById("hPage").value;
var count=document.getElementById("hCount").value;
$(document).ready(function() {
$("#pager").pager({ pagenumber: page, pagecount: count, buttonClickCallback: PageClick });});
PageClick = function(pageclickednumber)
{
window.location.href="jQuery_Page.aspx?page="+pageclickednumber;
}
</script>
window.location.href="jQuery_Page.aspx?page="+pageclickednumber; 在手机里应用应该是不支持的吧!!!能有一个具体的例子吗??后台使用php编写的哦!!
是打算用客户端来分页?还是利用JS输出分页控件样式呢?
如果客户端的话,可以使用dataTables看看。
用js
闪存(http://home.cnblogs.com/ing/)用的就是js分页,你可以参考一下:
/*#region Pager*/ var Pager = {}; Pager.PageIndex = 1; Pager.PageSize = 30; Pager.ShowPageCount = 5; Pager.TotalCount = 0; Pager.UrlFormat = location.href + "?page={0}"; Pager.ClickFunctionName = ""; Pager.Build = function (node) { $(node).html(''); var sumPage = parseInt((this.TotalCount + this.PageSize - 1) / this.PageSize); var start = this.PageIndex - this.ShowPageCount; var end = this.PageIndex + this.ShowPageCount; if (sumPage > (this.ShowPageCount * 2 - 1)) { if (start < 1) { start = 1; end = start + 2 * this.ShowPageCount; } else if (end > sumPage) { start = sumPage - 2 * this.ShowPageCount; end = sumPage; } } else { start = 1; end = sumPage; } var fragment = document.createDocumentFragment(); if (this.PageIndex > 1) { fragment.appendChild(this.BuildLink("< Prev", this.PageIndex - 1)); if (this.PageIndex > this.ShowPageCount) { fragment.appendChild(this.BuildLink(1, 1)); } if (start > 2) { fragment.appendChild(document.createTextNode("···")); } } for (i = start; i <= end; i++) { if (i == this.PageIndex) { var span = document.createElement("span"); $(span).prop("class", "current"); span.innerHTML = this.PageIndex; fragment.appendChild(span); } else { fragment.appendChild(this.BuildLink(i, i)); } } if (this.PageIndex < sumPage) { if (end < sumPage) { fragment.appendChild(document.createTextNode("···")); fragment.appendChild(this.BuildLink(sumPage, sumPage, this.TotalCount)); } fragment.appendChild(this.BuildLink("Next >", this.PageIndex + 1, this.TotalCount)); } $(node).html(fragment); } Pager.BuildLink = function (pageTitle, pageIndex) { var a = document.createElement("a"); if (this.ClickFunctionName) { a.href = "javascript:void(0);"; var js = this.ClickFunctionName + "(" + pageIndex + ");Pager.SetCurrent(" + pageIndex + ");"; a.onclick = function() { eval(js); } } else { a.href = this.UrlFormat.replace("{0}", pageIndex); } a.innerHTML = pageTitle; return a; } Pager.SetCurrent = function (pageIndex) { this.PageIndex = pageIndex; if (this.PageIndex > 1) { this.Build($("#pager_top")); } this.Build($("#pager_bottom")); } /*#endregion Pager*/
学习学习