基于jquery實現(xiàn)的表格分頁實現(xiàn)代碼
更新時間:2011年06月21日 22:57:38 作者:
該方法的運用是從后臺數(shù)據(jù)庫中一次性取出所有的數(shù)據(jù),運用Jquery把一部分?jǐn)?shù)據(jù)隱藏起來,事實上數(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)建時間<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,這個在后面Js文件的引用中十分重要,一句$("#userTable").tablePaging();會去執(zhí)行jquery.table.js中的代碼。
后臺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");
}
運用jquery實現(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)建時間<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,這個在后面Js文件的引用中十分重要,一句$("#userTable").tablePaging();會去執(zhí)行jquery.table.js中的代碼。
后臺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");
}
運用jquery實現(xiàn)表格分頁打包
相關(guān)文章
asp.net網(wǎng)站開發(fā)中用jquery實現(xiàn)滾動瀏覽器滾動條加載數(shù)據(jù)(類似于騰訊微博)
騰訊微博提供兩種加載數(shù)據(jù)的方式,一種是分頁,一種是滾動瀏覽器滾動條加載數(shù)據(jù),分頁功能我想大家都做得太多了,今天我與大家分享一下我用滾動條滾動加載數(shù)據(jù)2012-03-03
jquery實現(xiàn)table鼠標(biāo)經(jīng)過變色代碼
table鼠標(biāo)經(jīng)過變色的效果想必大家都有見到過吧,其實實現(xiàn)很簡單,在本文有個不錯的示例,感興趣的朋友可以學(xué)習(xí)下2013-09-09
jQuery實現(xiàn)簡單的下拉菜單導(dǎo)航功能示例
這篇文章主要介紹了jQuery實現(xiàn)簡單的下拉菜單導(dǎo)航功能,涉及jQuery針對頁面元素的遍歷與節(jié)點修改相關(guān)操作技巧,需要的朋友可以參考下2017-12-12
jQuery獲得頁面元素的絕對/相對位置即絕對X,Y坐標(biāo)
jQuery獲得頁面元素的絕對X,Y坐標(biāo),可以用offset()方法,下面有個不錯的坐標(biāo)大家可以參考下2014-03-03

