1.先有静态的页面:

<div class="col-xs-12">
<table id="tbtablesaleinfo" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th class="center">
角色名称
</th>
<th>操作</th>
</tr>
</thead>
<tbody id="datatbody">
</tbody>
</table>
<nav aria-label="...">
<ul class="pager">
<li><button class="btn btn-white" onclick="datatop()" >首页</button></li>
<li><button class="btn btn-white" onclick="datapageup()" >上一页</button></li>
<li><button class="btn btn-white" onclick="datapagedown()" >下一页</button></li>
<li><button class="btn btn-white" onclick="datapagefooter()">尾页</button></li>
</ul>
</nav>
<!-- PAGE CONTENT ENDS -->
</div><!-- /.col -->

  

2.相对应的js方法:

function convertstring(val){
if(null == val || undefined == val || "" == val){
return "";
}
return val;
} var jsonpagesaleinfo = {
pageCount:1,
pagecurrpage:1,
pageSize:10,
pageCountSize:0
};
var localhost = sessionStorage.getItem("localhost");
var name = sessionStorage.getItem("name");
$("small[id='username']").html(convertstring(name));
var dealerId = sessionStorage.getItem("dealerId"); //goods頭:
function datatop(){
//跳转到第一页:
if(1 == jsonpagesaleinfo.pagecurrpage){
return;
}else{
jsonpagesaleinfo.pagecurrpage = 1;
}
querysaleinfotable();
}
//goods上:
function datapageup(){
if(1 == jsonpagesaleinfo.pagecurrpage){
return;
}else{
jsonpagesaleinfo.pagecurrpage = jsonpagesaleinfo.pagecurrpage - 1;
}
//模仿强哥方法:
querysaleinfotable();
}
//goods下: function datapagedown(){
console.log(jsonpagesaleinfo.pageCount);
console.log(jsonpagesaleinfo.pagecurrpage);
if(jsonpagesaleinfo.pageCount == jsonpagesaleinfo.pagecurrpage){
return;
}else{
jsonpagesaleinfo.pagecurrpage = jsonpagesaleinfo.pagecurrpage + 1;
}
//模仿强哥方法:
querysaleinfotable();
}
//goods尾:
function datapagefooter(){
if(jsonpagesaleinfo.pageCount == jsonpagesaleinfo.pagecurrpage){
return;
}else{
jsonpagesaleinfo.pagecurrpage = jsonpagesaleinfo.pageCount;//设置为末尾.
}
querysaleinfotable();
} //设置为1,总是找到第一页不久得啦.
function querysaleinfotableMd(){
jsonpagesaleinfo.pagecurrpage = 1;
querysaleinfotable(); }
//分页方法:
function querysaleinfotable(){ //获取参数的值:
var data = {
"pageSize" : jsonpagesaleinfo.pageSize,
"pageindex":jsonpagesaleinfo.pagecurrpage
};
$.ajax({
url: localhost+"/role/lytacequeryrole",
data:JSON.stringify(data),
dataType:'json',
type:'post',
contentType:'application/json',
success:function(data){
var datajson = data.target.pagedata;
$("#datatbody").empty();
jsonpagesaleinfo.pagecurrpage = data.target.pageindex;//当前页码;
jsonpagesaleinfo.pageCountSize = data.target.pagecount;//总条数;
jsonpagesaleinfo.pageCount = data.target.pagePagecount;//总页码:
$("#pageindex").html(jsonpagesaleinfo.pagecurrpage);
$("#pagecountsize").html(jsonpagesaleinfo.pageCountSize);
$("#pagecount").html(jsonpagesaleinfo.pageCount);
if(null != datajson && datajson.length > 0){
for(var i = 0; i < datajson.length; i++){
$("#datatbody").append(createtr(
convertstring(datajson[i].id),
convertstring(datajson[i].name)
));
}
}
}
});
} //传递参数:
function createtr(a,b){
//<td>'+k+'</td>详情:
var str = '<tr><td style="display:none;">'+a+'</td><td class="col-xs-6">'+b+'</td><td><button class="btn btn-link" onclick="editMethod(this);">修改</button></td></tr>';
return str;
}
$(function(){
//日期插件:
$('.date-picker').datepicker({autoclose:true}).next().on(ace.click_event, function(){
$(this).prev().focus();
});
querysaleinfotable();
//$("#purchaseStatus").chosen({
// search_contains: true,
// disable_search_threshold: 10
//});
});
//点击查看详情,去详情页面:
function logistics(val){
//alert('点击我去详情!');
//window.location.href = 'purchaseinfotable.html?id='+$(val).parent().parent().find('td:eq(0)').text();
}
//修改界面:
function editMethod(val){
window.location.href = "authoritymanagerEdit.html?id="+$(val).parent().parent().find('td:eq(0)').text();;
}
//增加界面:
function preupdateMethod(){
window.location.href = "authoritymanagerEdit.html?id=-1";
}

  

十分简易的table动态加载就出来啦,还是比较码放,下次发angularjs动态获取数据table。

 

(网页)table加上分页,优点可随便加样式的更多相关文章

  1. Display Tag Lib Table进行分页

    Display Tag Lib是一个标签库,用来处理jsp网页上的Table,功能非常强,可以对的Table进行分页.数据导出.分组.对列排序等等,反正我在做项目时需要的功能它都给我提供了,而且使用起 ...

  2. html中使用js+table 实现分页

    本文在html中利用js+table实现分页.主要思想是先对table中的所有数据隐藏,然后通过当前页面(currPageNum)来计算当前页要显示的行,并显示出来,首页.下一页.上一页.尾页都依此来 ...

  3. mybatis分页插件以及懒加载

    1.   延迟加载 延迟加载的意义在于,虽然是关联查询,但不是及时将关联的数据查询出来,而且在需要的时候进行查询. 开启延迟加载: <setting name="lazyLoading ...

  4. MySQL+Service+Servlet+Jsp实现Table表格分页展示数据

    下面以一个示例讲解如何使用MySQL+Service+Servlet+Jsp实现Table表格分页展示数据: eg:请假管理系统 要求如下: 一.打开首页页面, 访问查询请假记录的 servlet , ...

  5. bootstrap table 服务器端分页例子分享

    这篇文章主要介绍了bootstrap table 服务器端分页例子分享,需要的朋友可以参考下 1,前台引入所需的js 可以从官网上下载 复制代码代码如下: function getTab(){var ...

  6. 利用JS实现HTML TABLE的分页

    有时候table的列数太长,不利于使用者查询,所以利用JS做了一个table的分页,以下为相关代码 一.JS代码 <script type="text/javascript" ...

  7. python之~【空格】可不能随便加唷~

    上个礼拜学习从.proto文件转xxpb2.py文件的时候,明明成功了的. 结果周末的时候在家里,以及今天周一来到公司电脑,都遇到同样的一个问题. 我就纳闷了.这个路径确实存在呀. 而且我找遍了搜索引 ...

  8. Footnotes for tables in latex - 为latex的table加上footnotes

    参考: Footnotes for tables in LaTeX Footnote in tabular environment Footnotes for tables in latex - 为l ...

  9. Jquery前端分页插件pagination同步加载和异步加载

    上一篇文章介绍了Jquery前端分页插件pagination的基本使用方法和使用案例,大致原理就是一次性加载所有的数据再分页.https://www.jianshu.com/p/a1b8b1db025 ...

随机推荐

  1. 深入理解OkHttp源码(二)——获取响应

    首先先看一张流程图,该图是从拆轮子系列:拆 OkHttp 中盗来的,如下: 在上一篇博客深入理解OkHttp源码(一)——提交请求中介绍到了getResponseWithInterceptorChai ...

  2. java.sql.SQLException: The SQL statement must not be null or empty.这个错误

    今天发现了这个错误 java.sql.SQLException: The SQL statement must not be null or empty. 并且看了些网页:综合说下这个错误. 一般都是 ...

  3. centos7非centos标准服务 /etc/init.d/service_name start || stop 启动异常

    公司自己写的java程序,在centos7系统执行/etc/init.d/service_name start||stop的时候报错: grafana二次开发的程序 [root@docp1 init. ...

  4. Mysql 调优和水平扩展思路

    系统调优参数 一些比较重要的参数: back_log:back_log值指出在MySQL暂时停止回答新请求之前的短时间内多少个请求可以被存在堆栈中.如果MySql的连接数据达到max_connecti ...

  5. SpringCloud入门之Spring Boot多环境配置切换指南

    在 spring boot 中,有两种配置文件,一种是application.properties,另一种是application.yml,两种都可以配置spring boot 项目中的一些变量的定义 ...

  6. 使用3D Slicer对图像进行配准

    在进行深度学习之前,我们需要图像进行一些预处理操作,其中配准是很重要的一环,以下将介绍使用软件3D Slicer来进行图像配准 3D Slicer是(1)一个软件平台,用以图像分析(包括配准和实时编辑 ...

  7. [转]virtualBox实现主机和虚拟机相互ping通,配置静态IP地址

    本文转自:https://blog.csdn.net/u010486658/article/details/70871940 背景: 需要在linux上安装软件用来练习,但是需要将安装包发送到linu ...

  8. C#泛型。

    作用: 使用泛型可以实现算法重用. class Program { static void Main(string[] args) { MyClass<string> myClass = ...

  9. UML 序列图

    序列图      序列图主要用于按照交互发生的一系列顺序,显示对象之间的这些交互.显示不同的业务对象如何交互,对于交流当前业务如何进行很有用.序列图是一个用来记录系统需求,和整理系统设计的好图.序列图 ...

  10. https创建请求UrL报错: 未能为 SSL/TLS 安全通道建立信任关系

    1.项目中异常报错如下: 2.百度结果:原来是 网站没有使用SSL证书或者是SSl证书失效了的缘故. 3.具体解决方案如下: )导入命名空间 using System.Net.Security; us ...