首页编程jquery分页,请问如何用jquery 实现html页面的分页查询

jquery分页,请问如何用jquery 实现html页面的分页查询

编程之家2023-11-05199次浏览

大家好,今天来为大家解答jquery分页这个问题的一些问题点,包括请问如何用jquery 实现html页面的分页查询也一样很多人还不知道,因此呢,今天就来为大家分析分析,现在让我们一起来看看吧!如果解决了您的问题,还望您关注下本站哦,谢谢~

jquery分页,请问如何用jquery 实现html页面的分页查询

jQuery分页插件pagination具体怎么用求详细教程

本文实例为大家分享了jQuery Pagination分页插件的具体代码,供大家参考,具体内容如下

一、引用CSS和JS:

<link rel="external nofollow" 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>

二、HTML:

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

三、JS:

jquery分页,请问如何用jquery 实现html页面的分页查询

$(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()为翻页调用次函数。 prev_text:"上一页", next_text:"下一页", items_per_page: 10,//每页的数据个数 num_display_entries: 1,//两侧首尾分页条目数 current_page: page,//当前页码 num_edge_entries: 11//连续分页主体部分分页条目数});});

四、后台代码:

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

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

请问如何用jquery 实现html页面的分页查询

首先你需要一个pageBean类,用来定义一些分页需要的数据!

public class PageBean<T>{

jquery分页,请问如何用jquery 实现html页面的分页查询

private int pageCount= 0;//总页数

private List<T> pageData= null;//当前页数据集

private int pageSize= 10;//每页大小

private int currentPage= 1;//当前页

private long totalRecord= 0;//总记录数

private int beginIndex= 0;//分页起始记录号

private int endIndex= 1;//分页结束记录号

public int getPageCount(){

pageCount=(int)(totalRecord+ pageSize-1)/pageSize;

return pageCount;

}

public void setPageCount(int pageCount){

this.pageCount= pageCount;

}

public List<T> getPageData(){

return pageData;

}

public void setPageData(List<T> pageData){

this.pageData= pageData;

}

public int getPageSize(){

return pageSize;

}

public void setPageSize(int pageSize){

this.pageSize= pageSize;

}

public int getCurrentPage(){

if(currentPage< 1){

currentPage= 1;

}

return currentPage;

}

public void setCurrentPage(int currentPage){

this.currentPage= currentPage;

}

public long getTotalRecord(){

if(totalRecord< 0){

totalRecord= 0;

}

return totalRecord;

}

public void setTotalRecord(long totalRecord){

this.totalRecord= totalRecord;

}

public int getBeginIndex(){

beginIndex=(currentPage- 1)* pageSize+1;

return beginIndex;

}

public void setBeginIndex(int beginIndex){

this.beginIndex= beginIndex;

}

public int getEndIndex(){

endIndex= currentPage* pageSize;

return endIndex;

}

public void setEndIndex(int endIndex){

this.endIndex= endIndex;

}

}

页面上,使用jQuery的Ajax发送后台请求信息:

$.ajax({

type:"post",

url:"requestPage",

dataType:"json",

data:{这里就是封装数据的地方,比如你要到第二页的时候,在这之前要读取当前的页数,并进行适当的判断,是键值对的形式例如:"current":1,"pageSize":10},

success:function(data){

这里是返回json字符串

var jsonObj=$(data);

然后解析遍历json

$.each(data.pageData,function(index,item){

这个回调函数里面的第一个参数是下标,第二个参数是集合里面的单个对象

然后生成显示…………结束

});

}

}):

使用jqueryMobile怎么分页

1、jquery-mobile-iscrollview下载

解压后的\jquery-mobile-iscrollview-master\jquery-mobile-iscrollview-master\demo\source路径下是需要引用的js和css文件

\jquery-mobile-iscrollview-master\jquery-mobile-iscrollview-master\demo\build路径下是各个jquery mobile版本下的列表和滚动翻页的例子

在该路径下,我选择了pull_14.html文件,用chrome打开后,发现下面的导航栏变形,将

<link rel="external nofollow" href="stylesheets/demo.css" media="screen" rel="stylesheet" type="text/css"/>

<script src="javascripts/demo.js" type="text/JavaScript"></script>

去掉后,下面的导航栏正常了

页面中引用的pull-example.js文件是上拉、下拉事件的处理,只需要将gotPullDownData和gotPullUpData函数修改一下即可实现自己需要加载的数据

2、直接测试该功能没有什么问题,当把该翻页的页面链接到其他页面上时,通过链接打开该页面,下面的导航栏又出现了问题

后来发现,这是问题可能是由于jqm的外部页面链接引起的错。jqm在使用外部链接打开另一个页面时,会使用ajax读取需要打开的文件,然后将该文件动态加载到已经打开的页面的后面,jqm只加载文档中取出的第一个页面(第一个带有role="page"的div),其他内容都将被忽略。

后来,将列表页面(b.html)所有加载的css和js的标签放到链接该页面的页面(a.html)的<head>标签中。

[html] view plain copy

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<meta name="viewport"

content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/>

<meta name="apple-mobile-web-app-capable" content="yes"/>

<meta name="apple-mobile-web-app-status-bar-style" content="black"/>

<link rel="stylesheet" rel="external nofollow" href="../jquery.mobile-1.4.2.min.css" type="text/css">

<link rel="external nofollow" href="../jquery.mobile.iscrollview.css" media="screen"

rel="stylesheet" type="text/css"/>

<link rel="external nofollow" href="../jquery.mobile.iscrollview-pull.css"

media="screen" rel="stylesheet" type="text/css"/>

<script src="../jquery.js" type="text/javascript"></script>

<script>

$(document).bind("mobileinit", function(){

//容许ajax跨域访问

$.mobile.allowCrossDomainPages= true;

});

</script>

<script src="../jquery.mobile-1.4.2.min.js"

type="text/javascript"></script>

<script src="../javascripts/iscroll.js" type="text/javascript"></script>

<script src="../javascripts/jquery.mobile.iscrollview.js"

type="text/javascript"></script>

<script src="../javascripts/pull-example.js" type="text/javascript"></script>

当链接打开该页面后,列表页面稳定了

3、jquery-mobile-iscrollview中引用的jqm框架的版本没有项目中的高,试着将jqm的版本替换为项目中使用的版本后,该功能依旧没有出现问题

jquery怎么动态实现表格分页

利用Ajax获取服务器数据,实现分页功能。

ajax请求代码:

$.ajax({

type:"post",

contentType:"application/json",

url:"../Backstage/AdminService.asmx/GetAdminList",

data:JSON.stringify({Name:user}),

success:function(result){

varjson=eval('('+result.d+')');

reTB(json.ds);

},

error:function(response){

varr=jQuery.parseJSON(response.responseText);

alert("Message:"+r.Message);

}

})

在表格下面放置按钮“上一页”、“下一页”,当点击的时候执行上面的请求代码,再将返回的数据填充到表格中。

POST方法可以是多样的,你可以写到aspx页面的后台进行处理,也可以建一个一般处理程序,WCF、服务器引用等。

提示:当你点击下一页的时候肯定要判断当前的页面是第几页,所以在页面中要进行保存。

如有不明之处,请继续追问,望采纳!

好了,关于jquery分页和请问如何用jquery 实现html页面的分页查询的问题到这里结束啦,希望可以解决您的问题哈!

广州网站设计公司,广州有名的大型网站设计公司有哪些百度竞价软件(哪款软件是用于百度竞价推广的)