bootstrap table hideRow显示行的方法

bootstrap table hideRow方法用来控制移除某一行数据),可以根据index索引和uniqueId唯一ID条件来隐藏行。

hideRow方法

参数名称参数说明
index行索引0开始,需要显示的行
uniqueId唯一字段值

代码例子

 //根据index显示行
   $('#table').bootstrapTable('hideRow', { index: 1 });
 
 //根据唯一字段显示行
  $('#table').bootstrapTable({  
        toolbar:"#toolbar", 
        uniqueId:"Id",//设置唯一字段
        data:data,
        columns: columns,  
   }); 
  $('#table').bootstrapTable('hideRow', { uniqueId: 12 })

在线试一试 

完整例子

<!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 updateCell在线例子</title>
    <style>
        .table-demo {
            width: 80%;
            margin: 30px auto 0px auto;
        }
      .titles {
  float: right;
  clear: both;
}
    </style>
</head>
<body>
  <div id="toolbar">
    <button onclick="hideByIndex()">根据index隐藏第2行</button> 
    <button onclick="showByIndex()">根据index显示第2行</button> 
    <button onclick="hideByUniqueId()">根据uniqueId隐藏第2行</button> 
    <button onclick="showByUniqueId()">根据uniqueId显示第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", 
        uniqueId:"Id",
        data:data,
        columns: columns,  
      });
      
     function hideByIndex()
     {
       $('#table').bootstrapTable('hideRow', { index: 1 }) 
     }
      
     function showByIndex()
     {
       $('#table').bootstrapTable('showRow', { index: 1 }) 
     }
     
       function hideByUniqueId()
     {
       $('#table').bootstrapTable('hideRow', { uniqueId: 12 }) 
     }
      
     function showByUniqueId()
     {
       $('#table').bootstrapTable('showRow', { uniqueId: 12 }) 
     }
     
      
    </script>
</body>
</html>