前言:BootstrapTable基于Bootstrap,Bootstrap基于jquery,所以需要引入jquery后再引入bootstrap。

  1. <link href="${ctx}/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="${ctx}/assets/plugins/bootstrap-datatable/bootstrap-table.min.css">
    <script src="${ctx}/assets/plugins/jquery/jquery-2.1.4.min.js"></script>
    <script src="${ctx}/assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="${ctx}/assets/plugins/bootstrap-datatable/bootstrap-table.min.js"></script>
    <script src="${ctx}/assets/plugins/bootstrap-datatable/bootstrap-table-zh-CN.min.js"></script>
    <link rel="stylesheet" href="${ctx}/assets/font/font-awesome/4.5.0/css/font-awesome.min.css"> //icon:官网

通过 JavaScript 的方式

通过表格 id 来启用 bootstrap table。

文档链接戳这里

  1.  

<div class="box-body">
     <div id="toorbar" class="btn-group">
       <shiro:hasPermission name="admin:ordervip:create">
       <button id="addBtn" type="button" class="btn btn-default">
         <i class="glyphicon glyphicon-plus"></i>新增订单
       </button>
       </shiro:hasPermission>
     </div>
     <table id="table"></table>
  </div>

  1. function initTable() {

$("#table").bootstrapTable({
         url: "${aapi}/orderVip/list",   //服务器数据加载地址,与末尾sidePagination参数设置为server对应。
         columns: [{             //列配置项,橙名为列参数,本文介绍有限,具体有哪些可以详细看文档介绍。
              field: 'orderNo',
              title: '订单编号',
              formatter: function(value, row, index) {  // value:field的值,row:行数据,用row.createdDtm找发起时间字段,index:行下标
                 return [
                       '<shiro:hasPermission name="admin:ordervip:detail">

<a class="detail ml10" href="javascript:void(0)" title="订单详情">',
                       value, '</a></shiro:hasPermission>',
                       '<shiro:lacksPermission name="admin:ordervip:detail">', value,
                       '</shiro:lacksPermission>'
                       ].join('');
                   },
              events: {
                       'click .detail': function(e, value, row, index) {  
                             $.FORM.showFormDialog({    //bootstrap-dialog与app-jquery-dialog.js结合使用,下面的文章中详细阐述。

title: "订单详情",
                               isReadOnly: true,
                               dataSource: "${aapi}/orderVip/detail/2/" + row.orderNo,
                               templateUrl: '${aapi}/page/custom/vipOrderDetail'
                             });
                        }
                      }
              }, {
              field: 'createdDtm',
              title: '发起时间'
              }, {
              field: 'cusName',
              title: '发起人'
              }, {
              field: 'splitDtm',
              title: '拆单时间'
              }, {
              field: 'splitnum',
              title: '拆单数量'
              }, {
              field: 'type',
              title: '类型',
              formatter: function(value, row, index) {
                            if(value == '0') {
                            return "维修";
                            }
                            if(value == '1') {
                               return "搬运";
                            }
                            if(value == "1,0") {
                               return "搬运,维修"
                            }
                         }
              }, {
              field: 'state',
              title: '订单状态',
              formatter: function(value, row, index) {
                            if(typeof(value) == 'undefined' || value == "0") {
                               return "未拆分";
                            }
                            if(value == '1') {
                               return "已拆分";
                            }

}
              }, {
              field: 'remark',
              title: '备注'
              }, {
              field: 'file',
              title: '文件',
              formatter: function(value, row, index) {
                            if(row.orderFile == undefined) {
                                 return "--";
                            } else {
                                 return '<shiro:hasPermission name="admin:ordervip:download"><a class="download ml10" href="javascript:void(0)" title="下载表格">                                  <i class="fa fa-file-o" aria-hidden="true"></i></a></shiro:hasPermission>';
                            }
                         },
              events: {
                        'click .download': function(e, value, row, index) {
                             window.open('${aapi}/orderVip/downLoad/' + row.orderNo, '_self');
                         }

}
              }, {
              field: 'opt',
              title: '操作',
              formatter: function(value, row, index) {
                         return [
                                '<shiro:hasPermission name="admin:ordervip:splitorder">

<a class="split ml10" href="javascript:void(0)" title="拆分订单">

<i class ="fa fa-wrench" aria-hidden="true"></i></a></shiro:hasPermission>',
                                '<shiro:hasPermission name="admin:ordervip:update">

<a class="edit ml10" href="javascript:void(0)" title="修改订单">

<i class="glyphicon glyphicon-edit"></i></a></shiro:hasPermission>',
                                '<shiro:hasPermission name="admin:ordervip:delete">

<a class="cancel ml10" href="javascript:void(0)" title="取消订单">

<i class="glyphicon glyphicon-ban-circle"></i></a></shiro:hasPermission>'
                                ].join('');
                         },    //紫色为添加图标(icon),插件:font-awesome,效果图见底部。
              events: {
                        'click .split': function(e, value, row, index) {
                             $.FORM.showFormDialog({
                                 title: "拆分VIP订单",
                                 isReadOnly: true,
                                 dataSource: "${aapi}/orderVip/detail/2/" + row.orderNo,
                                 templateUrl: '${aapi}/page/custom/vipOrderSplit'
                             });

},
                        'click .edit': function(e, value, row, index) {
                        if(row.state == '1') {
                    $.NOTIFY.showNotice('提示', '不能修改已拆分的订单!');

} else {
                                $.FORM.showFormDialog({
                        title: "修改VIP订单",
                                     postUrl: "${aapi}/orderVip/update",
                                     dataSource: "${aapi}/orderVip/detail/2/" + row.orderNo,
                      isReadOnly: false,
                      templateUrl: '${aapi}/page/custom/vipModifyForm',
                      formId: "#vipForm",
                      postType: "multipart",
                      data: {
                          pid: 0,
                          pname: "--",
                          level: 0
                          },
                      onPostSuccess: function() {
                          $("#table").bootstrapTable("refresh");
                      }
                    });
                  }

              },
              'click .cancel': function(e, value, row, index) {
                  if(row.state == '1') {
                      $.NOTIFY.showNotice('提示', '不能删除已拆分的订单!');

                  } else {
                      $.FORM.showConfirm({
                          title: "提示",
                          message: "您确认要取消订单【" + row.orderNo + "】?",
                          url: "${aapi}/orderVip/delete/" + row.orderNo,
                          autoClose: true,
                          successTitle: "成功",
                          successMessage: "订单【" + row.orderNo + "】已取消!",
                          onSuccess: function() {
                                 $("#table").bootstrapTable("refresh");
                          }
                       });
                               }

}
         }
         }],
      queryParams: function(params) {
          return $.extend({}, params, searchformData);    //请求服务器数据时,你可以通过重写参数的方式添加一些额外的参数,本项目中用于自定义表格的查询,于别的文章详细阐述。
          },
         toolbar: "#toolbar",  //一个jQuery 选择器,指明自定义的toolbar(工具栏),将需要的功能放置在表格工具栏(默认)位置。
         sidePagination: "server",  //设置在哪里进行分页,可选值为 'client' 或者 'server'。设置 'server'时,必须设置 服务器数据地址(url)或者重写ajax方法
         pageNumber: 1,    //如果设置了分页,首页页码
         pageSize: 10,   //如果设置了分页,页面数据条数
         pageList: [
             10, 20, 50, 100, 200   //如果设置了分页,设置可供选择的页面数据条数。设置为All 则显示所有记录。
         ],
         pagination: true,  //设置为 true 会在表格底部显示分页条
         showRefresh: true, //显示 刷新按钮
         showColumns: true, //是否显示 内容列下拉框
         searchOnEnterKey: true,  //设置为 true时,按回车触发搜索方法,否则自动触发搜索方法

search:true   //是否启用搜索框

});
    }

  1. initTable();

分页使用后台代码写,并且返回参数order=asc&limit=10&offset=0(正序,10条,从0开始),不懂这些值是怎么设置的= =

url: http://127.0.0.1:8081/piano/a/orderVip/list?order=asc&limit=10&offset=0

请求成功后的表格如下图所示:

(本篇内容还结合了bootstrap-dialog的内容。在接下来的文章中详细介绍。)

Bootstrap Table的使用的更多相关文章

  1. BootStrap table使用

    bootstrap table git address https://github.com/wenzhixin/bootstrap-table 引入文件 <link rel="sty ...

  2. bootstrap Table 中给某一特定值设置table选中

    bootstrap Table 中给某一特定值设置table选中 需求: 如图所示:左边地图人员选定,右边表格相应选中. 功能代码: //表格和图标联动 function changeTableSel ...

  3. JS组件系列——表格组件神器:bootstrap table

    前言:之前一直在忙着各种什么效果,殊不知最基础的Bootstrap Table用法都没有涉及,罪过,罪过.今天补起来吧.上午博主由零开始自己从头到尾使用了一遍Bootstrap Table ,遇到不少 ...

  4. JS组件系列——表格组件神器:bootstrap table(二:父子表和行列调序)

    前言:上篇 JS组件系列——表格组件神器:bootstrap table 简单介绍了下Bootstrap Table的基础用法,没想到讨论还挺热烈的.有园友在评论中提到了父子表的用法,今天就结合Boo ...

  5. JS组件系列——表格组件神器:bootstrap table(三:终结篇,最后的干货福利)

    前言:前面介绍了两篇关于bootstrap table的基础用法,这章我们继续来看看它比较常用的一些功能,来个终结篇吧,毛爷爷告诉我们做事要有始有终~~bootstrap table这东西要想所有功能 ...

  6. JS组件系列——Bootstrap Table 冻结列功能IE浏览器兼容性问题解决方案

    前言:最近项目里面需要用到表格的冻结列功能,所谓“冻结列”,就是某些情况下表格的列比较多,需要固定前面的几列,后面的列滚动.遗憾的是,bootstrap table里自带的fixed column功能 ...

  7. JS组件系列——Bootstrap Table 表格行拖拽

    前言:之前一直在研究DDD相关知识,好久没更新JS系列文章了.这两天做了一个简单的业务需求,觉得效果还可以,今天在这里分享给大家,欢迎拍砖~~ 一.业务需求及实现效果 项目涉及到订单模块,那天突然接到 ...

  8. JS组件系列——Bootstrap Table 表格行拖拽(二:多行拖拽)

    前言:前天刚写了篇JS组件系列——Bootstrap Table 表格行拖拽,今天接到新的需要,需要在之前表格行拖拽的基础上能够同时拖拽选中的多行.博主用了半天时间研究了下,效果是出来了,但是感觉不尽 ...

  9. 后台系统组件:一丶bootstrap table

    http://www.cnblogs.com/landeanfen/p/4976838.html (bootstrap table) http://www.cnblogs.com/landeanfen ...

  10. Bootstrap Table Examples

    The examples of bootstrap table http://bootstrap-table.wenzhixin.net.cn/examples/ http://www.jq22.co ...

随机推荐

  1. 开始制作国产的 scratch

    首先分析下API和数据格式: https://api.scratch.mit.edu/proxy/featured  GET   23.235.37.162:443 返回数据与对应栏目: commun ...

  2. Service的启动方式

    Service的启动方式: 两种启动模式,一种是非绑定启动模式,另一种是绑定启动模式. 一.startservice方式启动 Intent intent = new Intent(this, Firs ...

  3. MySQL性能优化的最佳21条经验【转载】

    今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数据 ...

  4. Windows平台查看端口占用情况

    1.查看所有的端口占用情况 netstat -ano 协议    本地地址                     外部地址               状态                   PI ...

  5. postfix防垃圾邮件

    Postfix 2.x 打开/etc/postfix/main.cf文件,在其中增加如下的几行(如果相关的配置存在,就替换之): vi /etc/postfix/main.cf [...] smtpd ...

  6. Modal视图弹出方式

    Modal方式弹出页面: 1.Modal方式弹出页面在iOS中有很广泛的应用,比如UIImagePickerController等,Modal方式主要有以下几个作用: 检查登陆信息,Modal出登陆页 ...

  7. ASP.NET获取客户端信息,获取客户端IP等等

    山上明月 ASP.NET能知道的东西 获取服务器电脑名: Page.Server.ManchineName 获取用户信息: Page.User 获取客户端电脑名:Page.Request.UserHo ...

  8. 介绍XXTEA加密算法及其C实现

    介绍XXTEA加密算法及其C实现 http://en.wikipedia.org/wiki/XXTEA “微型加密算法(TEA)及其相关变种(XTEA,Block TEA,XXTEA)都是分组加密算法 ...

  9. 安卓常用 widget

    验证码 public class SpinnerImg extends ImageView { /** * 完成选择后启动另外一个spinner */ private ItemListener ite ...

  10. python注意事项

    以下基于python3.4.3 1.python3与python2不兼容 2.python语言正确的缩进很重要!事实上缩进是种语法 C中需要 { } 的的地方,python使用 : +缩进 实现 3. ...