bootstrap table getHiddenRows获取隐藏的行的方法

bootstrap table getHiddenRows获取隐藏的行,如果参数传入true会把隐藏的行显示但是不会返回隐藏的行,这点设计有点不合理。

getHiddenRows方法

参数名称参数说明
show默认为false,设置为true会把隐藏的行显示

代码例子

//获取隐藏的行
var rows=$('#table').bootstrapTable('getHiddenRows');
//显示全部隐藏的行,但是不会返回之前隐藏的行
$('#table').bootstrapTable('getHiddenRows',true);

在线试一试 

完整例子

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <script src="https://www.itxst.com/package/jquery-3.3.1/jquery.js"></script>
    <link href="https://www.itxst.com/package/bootstrap-4.3.1/css/bootstrap.css" rel="stylesheet" />
    <link href="https://www.itxst.com/package/bootstrap-table-1.15.3/bootstrap-table.css" rel="stylesheet" />
    <script src="https://www.itxst.com/package/bootstrap-table-1.15.3/bootstrap-table.js"></script> 
    <title>bootstrap table getHiddenRows在线例子</title>
    <style>
        .table-demo {
            width: 80%;
            margin: 30px auto 0px auto;
        }
      .titles {
  float: right;
  clear: both;
}
    </style>
</head>
<body>
  <div id="toolbar">
    <button onclick="getHideRows(1)">获取隐藏的行</button> 
    <button onclick="getHideRows(2)">显示隐藏的行</button> 
  </div>
    <div class="table-demo">
        <table id="table"  ></table>
    </div>
    <script>
        //设置需要显示的列
        var columns = [
        { 
          checkbox:true
        },
        { 
           field:"Id",  
          title: 'ID'
        }, {
            field: 'catalog',
            title: '分类'
        } ];
      var data= [{
            Id: 11,
            catalog: 'catalog 101', 
        }, {
            Id: 12,
            catalog: 'catalog 102', 
        }, {
            Id: 13,
            catalog: 'catalog 103', 
      } ];
     
     $('#table').bootstrapTable({  
        toolbar:"#toolbar",  
        data:data,
        columns: columns,  
      });
      $('#table').bootstrapTable('hideRow', { index: 1 });
      
     function getHideRows(icase)
     {
       var rows;
       if(icase===1)
       {
        rows=$('#table').bootstrapTable('getHiddenRows');
       }
       if(icase===2)
       {
        rows=$('#table').bootstrapTable('getHiddenRows',true);
       }
       alert(JSON.stringify(rows)); 
     }
  
     
    </script>
</body>
</html>