国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

Bootstrap Table使用心得總結

2019-11-19 18:47:00
字體:
來源:轉載
供稿:網友

之前一直在調研我們的管理后臺使用的表格控件,查詢到 : http://bootstrap-table.wenzhixin.net.cn的Bootstrap Table 感覺挺不錯,但是由于官方的文檔不是怎么的完善,導致自己的網絡數據請求一直沒有通過。

今天終于調試通過,在這里與大家分享一下。

一、相關的配置文件引入

<!-- jQuery文件。務必在bootstrap.min.js 之前引入 --><script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script><link rel="stylesheet" ><script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script><!-- bootstrap table --><link  rel="stylesheet"><script src="http://cdn.bootcss.com/bootstrap-table/1.11.0/bootstrap-table.min.js"></script><script src="http://cdn.bootcss.com/bootstrap-table/1.11.0/bootstrap-table-locale-all.js"></script><script src="http://cdn.bootcss.com/bootstrap-table/1.11.0/extensions/export/bootstrap-table-export.min.js"></script><!-- bootstrap table 包含excel導出,pdf導出 --><script src="https://rawgit.com/hhurz/tableExport.jquery.plugin/master/tableExport.js"></script><script src="http://cdn.bootcss.com/FileSaver.js/2014-11-29/FileSaver.min.js"></script>

注意!!!!! 這里的 tableExport.js并不是 bootcdn上的tableExport,使用的時候注意看作者,不到會導致無法導出excel

二、編寫表頭和工具欄

其實整個表頭的編寫非常簡單,只需要簡單的幾個配置就好。

注意,把每一個bean的屬性書寫在th中
注意綁定工具欄

可以參考如下配置

<!-- 工具欄的按鈕,可以自定義事件 --><div id="toolbar" class="btn-group"> <button type="button" class="btn btn-default"> <i class="glyphicon glyphicon-plus"></i> </button> <button type="button" class="btn btn-default"> <i class="glyphicon glyphicon-heart"></i> </button> <button type="button" class="btn btn-default"> <i class="glyphicon glyphicon-trash"></i> </button></div><table id="demo" class="table table-striped table-hover table-bordered"  data-toolbar="#toolbar" // 這里必須綁定工具欄,不然布局會錯亂 data-search="true"  data-show-refresh="true" data-show-columns="true" data-show-export="true" data-export-types="['excel']" data-export-options='{ // 導出的文件名 "fileName": "products",  "worksheetName": "products" }' > <thead> <tr>  <th width="3%" data-field="prodId">產品Id</th>  <th width="10%" data-field="nameOfProduct">產品名稱</th>  <th width="4%" data-field="categoryId">產品類別</th>  <th width="5%" data-field="domicileOfCapital">資本類型</th>  <th width="8%" data-field="underwriter">發行機構</th>  <th width="6%" data-field="managementInstitution">基金公司</th>  <th width="5%" data-field="managementInstitution2">管理機構</th>  <th width="3%" data-field="flag">角標</th>  <th width="7%" data-field="beginTime">上線時間</th>  <th width="7%" data-field="endTime">下線時間</th>  <th width="4%" data-field="status">發布狀態</th>  <th width="4%" data-field="fundRaisingStatus">募集狀態</th>  <th width="3%" data-field="totalScore">打分</th>  <th width="3%" data-field="modesOfGuaranteeScore">擔保</th>  <th width="3%" data-field="invsetmentTargetScore">投資</th>  <th width="3%" data-field="underwriterScore">發行</th>  <th width="3%" data-field="sourceOfPaymentScore">還款</th>  <th width="3%" data-field="issuerDescriptionScore">融資</th>  <th width="10%">操作</th> </tr> </thead></table>

三、綁定后端邏輯

因為,Bootstrap Table默認是使用了form表單的方式提交,其分頁參數與查詢參數都與我們的后端邏輯協議不一致。(官方就缺少這一部分的文檔)

所以,我們需要更具其協議做一個自定義的配置。

$(function() { $("#demo").bootstrapTable({ url: "http://ydjr.dev.chengyiwm.com/goldman-mgr/listProduct", sortName: "prodId", //排序列  striped: true, //

主站蜘蛛池模板:
绥德县|
保定市|
二连浩特市|
青州市|
武乡县|
仪征市|
灌南县|
烟台市|
贵南县|
石首市|
鄂伦春自治旗|
通州区|
湘潭市|
鄯善县|
汪清县|
五家渠市|
如东县|
连山|
隆化县|
鄱阳县|
即墨市|
藁城市|
锦屏县|
仙桃市|
荣昌县|
潼关县|
林周县|
郎溪县|
手游|
正阳县|
马关县|
英吉沙县|
祁门县|
台前县|
云南省|
牟定县|
新和县|
鸡泽县|
齐河县|
太湖县|
调兵山市|