基于jquery實(shí)現(xiàn)的表格分頁實(shí)現(xiàn)代碼
更新時(shí)間:2011年06月21日 22:57:38 作者:
該方法的運(yùn)用是從后臺(tái)數(shù)據(jù)庫中一次性取出所有的數(shù)據(jù),運(yùn)用Jquery把一部分?jǐn)?shù)據(jù)隱藏起來,事實(shí)上數(shù)據(jù)還是全部在html頁面中
具體代碼如下:
引用js和css文件有:
<link ID="skin" rel="stylesheet" type="text/css" href="css/config.css">
<script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript" src="js/skin.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.table.js"></script>
頁面代碼:
<table id="userTable" align="center" class="listtable" width="100%" bgcolor="#CCCCCC" cellSpacing="1" cellpadding="1" style="margin-top:5px;" >
<thead>
<tr class="fixheader">
<td noWrap width="5%">選擇</td>
<td noWrap width="10%">用戶ID<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td noWrap width="10%">用戶名稱<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td noWrap width="10%">所在科室<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td width="10%" noWrap>創(chuàng)建時(shí)間<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td width="10%" noWrap>創(chuàng)建人<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td width="10%" noWrap>菜單集名稱<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td width="10%" noWrap>是否有效<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
</tr>
</thead>
<tbody style="display:">
<c:forEach items="${userList}" var="smUser">
<tr height="22px" bgcolor="#F9FDFF" onmouseover="javascript:this.style.backgroundColor='#FFFFCC'; return true;" onMouseOut="javascript:this.style.backgroundColor='#F9FDFF'; return true;">
<td align="center"><input type="checkbox"></td>
<td class="tdc">${smUser.userId }</td>
<td class="tdc">${smUser.userName }</td>
<td class="tdc">${smUser.organCode }</td>
<td class="tdc">${smUser.createTime }</td>
<td class="tdc">${smUser.creator }</td>
<td class="tdc">${smUser.menusId }</td>
<td class="tdc">${smUser.valid }</td>
</tr>
</c:forEach>
</tbody>
</table>
<script language="javascript" type="text/javascript">
$("#userTable").tablePaging();
</script>
此處要特別注意的是要講table的表頭加上<thread></thread>標(biāo)簽,且注意此處的table的id為userTable,這個(gè)在后面Js文件的引用中十分重要,一句$("#userTable").tablePaging();會(huì)去執(zhí)行jquery.table.js中的代碼。
后臺(tái)action的代碼如下:
public ActionForward listUser(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
List<POJO> pojos = serviceSmUserImpl.findAll();
List<SmUser> smUserList = new ArrayList<SmUser>();
for(POJO pojo:pojos){
smUserList.add((SmUser)pojo);
}
request.setAttribute("userList",smUserList);
return mapping.findForward("smUserList");
}
運(yùn)用jquery實(shí)現(xiàn)表格分頁打包
引用js和css文件有:
復(fù)制代碼 代碼如下:
<link ID="skin" rel="stylesheet" type="text/css" href="css/config.css">
<script type="text/javascript" src="js/config.js"></script>
<script type="text/javascript" src="js/skin.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.table.js"></script>
頁面代碼:
復(fù)制代碼 代碼如下:
<table id="userTable" align="center" class="listtable" width="100%" bgcolor="#CCCCCC" cellSpacing="1" cellpadding="1" style="margin-top:5px;" >
<thead>
<tr class="fixheader">
<td noWrap width="5%">選擇</td>
<td noWrap width="10%">用戶ID<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td noWrap width="10%">用戶名稱<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td noWrap width="10%">所在科室<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td width="10%" noWrap>創(chuàng)建時(shí)間<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td width="10%" noWrap>創(chuàng)建人<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td width="10%" noWrap>菜單集名稱<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
<td width="10%" noWrap>是否有效<img src="images/up.png" style= "cursor:hand " alt="升序" align="absmiddle"><img src="images/down.png" style= "cursor:hand " alt="降序"align="absmiddle"></td>
</tr>
</thead>
<tbody style="display:">
<c:forEach items="${userList}" var="smUser">
<tr height="22px" bgcolor="#F9FDFF" onmouseover="javascript:this.style.backgroundColor='#FFFFCC'; return true;" onMouseOut="javascript:this.style.backgroundColor='#F9FDFF'; return true;">
<td align="center"><input type="checkbox"></td>
<td class="tdc">${smUser.userId }</td>
<td class="tdc">${smUser.userName }</td>
<td class="tdc">${smUser.organCode }</td>
<td class="tdc">${smUser.createTime }</td>
<td class="tdc">${smUser.creator }</td>
<td class="tdc">${smUser.menusId }</td>
<td class="tdc">${smUser.valid }</td>
</tr>
</c:forEach>
</tbody>
</table>
<script language="javascript" type="text/javascript">
$("#userTable").tablePaging();
</script>
此處要特別注意的是要講table的表頭加上<thread></thread>標(biāo)簽,且注意此處的table的id為userTable,這個(gè)在后面Js文件的引用中十分重要,一句$("#userTable").tablePaging();會(huì)去執(zhí)行jquery.table.js中的代碼。
后臺(tái)action的代碼如下:
復(fù)制代碼 代碼如下:
public ActionForward listUser(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
List<POJO> pojos = serviceSmUserImpl.findAll();
List<SmUser> smUserList = new ArrayList<SmUser>();
for(POJO pojo:pojos){
smUserList.add((SmUser)pojo);
}
request.setAttribute("userList",smUserList);
return mapping.findForward("smUserList");
}
運(yùn)用jquery實(shí)現(xiàn)表格分頁打包
您可能感興趣的文章:
- 基于Jquery實(shí)現(xiàn)表格動(dòng)態(tài)分頁實(shí)現(xiàn)代碼
- JQuery頁面的表格數(shù)據(jù)的增加與分頁的實(shí)現(xiàn)
- jquery 表格分頁等操作實(shí)現(xiàn)代碼(pagedown,pageup)
- 擴(kuò)展jquery實(shí)現(xiàn)客戶端表格的分頁、排序功能代碼
- 基于jQuery實(shí)現(xiàn)的無刷新表格分頁實(shí)例
- 基于jquery實(shí)現(xiàn)表格無刷新分頁
- jQuery給表格添加分頁效果
- 利用jQuery實(shí)現(xiàn)一個(gè)簡(jiǎn)單的表格上下翻頁效果
相關(guān)文章
asp.net網(wǎng)站開發(fā)中用jquery實(shí)現(xiàn)滾動(dòng)瀏覽器滾動(dòng)條加載數(shù)據(jù)(類似于騰訊微博)
騰訊微博提供兩種加載數(shù)據(jù)的方式,一種是分頁,一種是滾動(dòng)瀏覽器滾動(dòng)條加載數(shù)據(jù),分頁功能我想大家都做得太多了,今天我與大家分享一下我用滾動(dòng)條滾動(dòng)加載數(shù)據(jù)2012-03-03
jquery實(shí)現(xiàn)table鼠標(biāo)經(jīng)過變色代碼
table鼠標(biāo)經(jīng)過變色的效果想必大家都有見到過吧,其實(shí)實(shí)現(xiàn)很簡(jiǎn)單,在本文有個(gè)不錯(cuò)的示例,感興趣的朋友可以學(xué)習(xí)下2013-09-09
基于jquery實(shí)現(xiàn)的文字淡入淡出效果
這篇文章介紹了jquery實(shí)現(xiàn)的文字淡入淡出效果實(shí)例,有需要的朋友可以參考一下2013-11-11
jQuery實(shí)現(xiàn)簡(jiǎn)單的下拉菜單導(dǎo)航功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)簡(jiǎn)單的下拉菜單導(dǎo)航功能,涉及jQuery針對(duì)頁面元素的遍歷與節(jié)點(diǎn)修改相關(guān)操作技巧,需要的朋友可以參考下2017-12-12
jQuery獲得頁面元素的絕對(duì)/相對(duì)位置即絕對(duì)X,Y坐標(biāo)
jQuery獲得頁面元素的絕對(duì)X,Y坐標(biāo),可以用offset()方法,下面有個(gè)不錯(cuò)的坐標(biāo)大家可以參考下2014-03-03
自己動(dòng)手寫的jquery分頁控件(非常簡(jiǎn)單實(shí)用)
最近接了一個(gè)項(xiàng)目,其中有需求要用到j(luò)query分頁控件,上網(wǎng)也找到了需要分頁控件,各種寫法各種用法,都是很復(fù)雜,最終決定自己動(dòng)手寫一個(gè)jquery分頁控件,全當(dāng)是練練手了2015-10-10

