温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

bootstrap table方法之expandRow-collapseRow展开或关闭当前行数据

发布时间:2020-08-19 14:24:21 来源:脚本之家 阅读:144 作者:黄德根 栏目:web开发

本文实例为大家分享了bootstrap table展开或关闭当前行数据的具体代码,供大家参考,具体内容如下

<!DOCTYPE html>
<html>
<head>
 <title>expandRow-collapseRow</title>
 <meta charset="utf-8">
 <link rel="stylesheet" href="../assets/bootstrap/css/bootstrap.min.css" rel="external nofollow" >
 <link rel="stylesheet" href="../assets/bootstrap-table/src/bootstrap-table.css" rel="external nofollow" >
 <link rel="stylesheet" href="../assets/examples.css" rel="external nofollow" >
 <script src="../assets/jquery.min.js"></script>
 <script src="../assets/bootstrap/js/bootstrap.min.js"></script>
 <script src="../assets/bootstrap-table/src/bootstrap-table.js"></script>
 <script src="../ga.js"></script>
</head>
<body>
 <div class="container">
 <h2>expandRow-collapseRow</h2>
 <p></p>
 <div id="toolbar">
  <button id="button" class="btn btn-default">expandRow</button>
  <button id="button2" class="btn btn-default">collapseRow</button>
 </div>
 <table id="table"
  data-toggle="table"
  data-toolbar="#toolbar"
  data-height="460"
  data-detail-view="true"
  data-detail-formatter="detailFormatter"
  data-url="../json/data1.json">
  <thead>
  <tr>
  <th data-field="id">ID</th>
  <th data-field="name">Item Name</th>
  <th data-field="price">Item Price</th>
  </tr>
  </thead>
 </table>
 </div>
<script>
 var $table = $('#table'),
 $button = $('#button'),
 $button2 = $('#button2');

 $(function () {
 $button.click(function () {
  $table.bootstrapTable('expandRow', 1);
 });
 $button2.click(function () {
  $table.bootstrapTable('collapseRow', 1);
 });
 });

 function detailFormatter(index, row) {
 var html = [];
 $.each(row, function (key, value) {
  html.push('<p><b>' + key + ':</b> ' + value + '</p>');
 });
 return html.join('');
 }
</script>
</body>
</html>

官方演示地址

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持亿速云。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI