bootstrap-table 基础用法

摘要:
1.待添加的参考。

1.需要添加的引用。

    
    <script src="http://t.zoukankan.com/@Url.Content("~/js/jquery-2.1.1.js")"></script>
   <script src="http://t.zoukankan.com/@Url.Content("~/js/bootstrap.min.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/bootstrap-table.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/bootstrap-table-zh-CN.js")"></script>

2.完整的HTML

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/jquery-2.1.1.js")"></script>
    <link href="http://t.zoukankan.com/@Url.Content("~/css/bootstrap.min.css")" rel="stylesheet">
    <link href="http://t.zoukankan.com/@Url.Content("~/font-awesome/css/font-awesome.css")" rel="stylesheet">
    <link href="http://t.zoukankan.com/@Url.Content("~/css/plugins/iCheck/custom.css")" rel="stylesheet">
    <link href="http://t.zoukankan.com/@Url.Content("~/css/animate.css")" rel="stylesheet">
    <link href="http://t.zoukankan.com/@Url.Content("~/css/style.css")" rel="stylesheet">
    <script src="http://t.zoukankan.com/@Url.Content("~/js/jquery-ui-1.10.4.min.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/bootstrap.min.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/bootstrap-table.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/bootstrap-table-zh-CN.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/selectjs/bootstrap-select.js")"></script>
    <link href="http://t.zoukankan.com/@Url.Content("~/js/selectjs/bootstrap-select.min.css")" rel="stylesheet" />
    <script src="http://t.zoukankan.com/@Url.Content("~/js/selectjs/defaults-zh_CN.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/layer/layer.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/bootstrap.min.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/plugins/metisMenu/jquery.metisMenu.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/plugins/slimscroll/jquery.slimscroll.min.js")"></script>

    <!-- Custom and plugin javascript -->
    <script src="http://t.zoukankan.com/@Url.Content("~/js/inspinia.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/plugins/pace/pace.min.js")"></script>

    <!-- iCheck -->
    <script src="http://t.zoukankan.com/@Url.Content("~/js/plugins/iCheck/icheck.min.js")"></script>
    <!-- Jvectormap -->
    <script src="http://t.zoukankan.com/@Url.Content("~/js/plugins/jvectormap/jquery-jvectormap-2.0.2.min.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/plugins/jvectormap/jquery-jvectormap-world-mill-en.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/JsIFrame.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/layer/jquery.form.min.js")"></script>
    <script src="http://t.zoukankan.com/@Url.Content("~/js/ReportManage.js")"></script>


</head>

<body onload="IFrameResize()">
    <div style="background-color:#f3f3f3;height:100%">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">

                    <div class="ibox-title">
                        <h5>科技查新报告单管理</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a   data-toggle="dropdown" href="https://tool.4xseo.com/article/193862.html">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <table     data-toggle="table">
                            <thead>
                                <tr>
                                    <th data-field="ID" data-editable="true">ID</th>
                                    <th data-field="ReportNum">报告单编号</th>
                                    <th data-field="PrjName_CN" data-editable="true">委托单名称</th>
                                    <th data-field="Status" data-editable="true">状态</th>
                                    <th data-field="Addtime" data-editable="true">添加时间</th>
                                </tr>
                            </thead>
                        </table>

                    </div>

                </div>

            </div>
        </div>
    </div>
</body>
</html>

3. Ajax所在的JS代码  (    <script src="http://t.zoukankan.com/@Url.Content("~/js/ReportManage.js")"></script>)

var ztable = null;
$(function () {

    InitTable();
});

//初始加载table
function InitTable() {

    //先销毁表格  
    $('#cateTable').bootstrapTable('destroy');
    //初始化表格,动态从服务器加载数据  
    ztable = $('#cateTable').bootstrapTable(
          {
              url: '../NoveltyReport/GetAllReport',         //请求后台的URL(*)
              method: 'get',                      //请求方式(*)               //工具按钮用哪个容器
              striped: true,                      //是否显示行间隔色
              cache: false,                       //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
              pagination: true,                   //是否显示分页(*)
              search: true,
              sortOrder: "asc",                   //排序方式
              sidePagination: "client",
              pageNumber: 1,                       //初始化加载第一页,默认第一页
              pageSize: 10,                       //每页的记录行数(*)
              strictSearch: true,
              queryParamsType: "undefined",

              onPageChange: function (number, size) {

                  //PageChanged();
              },
              onClickCell: function (field, value, row, $element) {
                  if (field == 7) {
                      DeleteProxyByID(row.ID);
                  } else if (field == 6) {
                      location.href = "../NoveltyReport/ReportEdit?ReportID=" + row.ID + "&&ProxyID=" + row.ProxyID;
                  } else if (field == 9) {
                      SubitShenHe(row);
                  } else if (field == 8) {
                      location.href = "../Word/DownLoadReport?reportID="+row.ID;
                  }

              },

              clickToSelect: false,                //是否启用点击选中行
              //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
              uniqueId: "Id",                     //每一行的唯一标识,一般为主键列
              cardView: false,                    //是否显示详细视图
              detailView: false,                   //是否显示父子表
              columns: [

              {
                  field: 'Number',
                  title: '行号',
                  formatter: function (value, row, index) {
                      return index + 1;
                  }
              },
                  {
                      field: 'ID',
                      title: '序号',

                  },
                  {
                      field: 'ReportNum',
                      title: '报告单编号',
                      cellStyle: formatTableUnit

                  }, {
                      field: 'PrjName_CN',
                      title: '委托单名称',
                      cellStyle: formatTableUnit
                  },
                  {
                      field: 'Status',
                      title: '状态',
                      cellStyle: formatTableUnit

                  }, {
                      field: 'Addtime',
                      title: '添加时间',
                      cellStyle: formatTableUnit

                  },
                   {
                       title: "选择",
                       formatter: operateFormatter
                   },
              {
                  field: 'ProxyID',
                  title: '委托单号'
              },
              {
                  title: "下 载",
                  formatter: operateFormatterRed
              }, 
       

              ]
          }
      );
    $("#cateTable").bootstrapTable('hideColumn', 'ID');
    $("#cateTable").bootstrapTable('hideColumn', 'ProxyID');

}

function formatTableUnit(value, row, index) {

    return {
        css: {
            "overflow": "hidden",
            "white-space": "nowrap",
            "text-overflow": "ellipsis",
            " -webkit-line-clamp": "3"
        }
    }

}
function operateFormatter(value, row, index) {
    return [
        '<button type="button"   style="margin-right:15px;">查 看</button>',
    ].join('');
}

function operateFormatterRed(value, row, index) {
    return [
        '<button type="button"   style="margin-right:15px;">下 载</button>',
    ].join('');
}

function operateFormatterSH(value, row, index) {
    return [
    '<button type="button"   style="margin-right:15px;background-color:Blue;">提交审核</button>',
    ].join('');

}

function DeleteProxyByID(RepoprtID) {
    layer.confirm('您确定要删除数据?', {
        btn: ['确定', '取消'], //按钮
        offset: ["10%", "30%"]
    }, function () {
        $.post("../NoveltyReport/AjaxDeleteReport", { "RepoprtID": RepoprtID }, function (data) {
            if (data != "") {
                var rs = JSON.parse(data);
                if (rs.Result) {
                    layer.msg("删除成功!");
                    InitTable();
                } else {
                    layer.msg(rs.Msg);
                }
            }
        });
    }, function () {

    });

}

function SubitShenHe(row) {
    layer.confirm('您确定将报告单提交审核?', {
        btn: ['确定', '取消'], //按钮
        offset: ["10%", "30%"]
    }, function () {
        $.post("../NoveltyReport/SubReportRatify", { "RepoprtID": row.ID }, function (data) {
            if (data != "") {
                var rs = JSON.parse(data);
                if (rs.Result) {
                    layer.msg("提交审核成功!");
                    InitTable();
                } else {
                    layer.msg(rs.Msg);
                }
            }
        });
    }, function () {

    });

}

免责声明:文章转载自《bootstrap-table 基础用法》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Qt qss一些伪装态,以及margin与padding区别python 第三方库BeautifulSoup4文档学习(4)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

uglifyjs压缩批处理

uglifyjs. 据说是用来压缩JS文件的,据说还能优化JS,据说是基于node的,还据说比Google Closure Compiler更带感。 uglifyjs压缩批处理我们不可能每次都打开cmd去键入压缩执行代码,容易写错不说(如上面那个结果图),还耗时,想想都会让人疯掉。懒人有懒法,花了点功夫,折腾了一个批处理文件,以后,想要压缩JS,只要双击运...

js-滑块拼图登录验证

一、为什么会有滑块登录验证 很多网站为了防止机器人登录操作,往往会会添加一个滑块拼图验证,必须要拖拽拼成完整才能登录成功。 二、案例展示 刷新页面,即可产生随机位置的两个方块,只有图片滑块滑倒空白方块附近才能算验证成功,可以设置允许有几像素的误差;离目标较远会自动返回。 三、具体实现代码 <!DOCTYPE html> <h...

公众号微信支付流程-(转)

微信支付类型 微信支付实际上有很多种不同的类型,具体要使用哪一种就需要根据不同的应用场景来选择,官方给出的参考例子: 刷卡支付:用户打开微信钱包的刷卡的界面,商户扫码后提交完成支付。 公众号支付:用户在微信内进入商家H5页面,页面内调用JSSDK完成支付 扫码支付:用户打开"微信扫一扫“,扫描商户的二维码后完成支付 APP支付:商户APP中集成微信SD...

JS获取本机时间和实时动态时间代码

一、JS代码获取本机时间代码: 1、时间函数: 当前时间日期函数为: Date();  那么我们把当前时间赋值给一个变形now,然后下面方便调用即: now=Date(); 年: now.getFullYear(); 月: now.getMonth()+1; 日: now.getUTCDate(); 时: now.getHours(); 分: now.g...

用原生JS读写CSS样式的方法总结

为了日后方便查询,本人翻阅了一些资料总结了以下方法,仅限原生JS,如有不对的地方欢迎指出!只求大家看完觉得有学到点什么就OK了!   一、可以通过DOM节点对象的style对象(即CSSStyleDeclaration对象)来读写文档元素的CSS样式              如:var elm = document.getElementById('tes...

GSAP JS基础教程--使用缓动函数

今天来了解一下缓动easeing函数。 开始,如果你还没有GSAP的类包,可以到GreenSock的官网去下载最新版本的类包,或者直接点击这里​来下载 学习之前,先来准备一下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/...