使Bootstrap表行可单击

时间:2017-07-25 17:17:34

标签: javascript php html bootstrap-table

我想让我的行可点击并打开一个模态。这可能吗?这里发布的代码与我的不同。所以,我不知道如何处理我的代码。谢谢你的帮助。

这是我的代码:

<div class="container">
  <div class="col-md-12">
    <div class="panel panel-success">
      <div class="panel-heading "> 
        <span>Land<br></span>
      </div>

     <div class="panel-body">
        <div class="row">
          <div class="col-md-12">
           <table  id="table" data-show-columns="true" data-height="500">
           <tr>
              <th>#</th>
              <th>ID</th>
              <th>Location</th>
              <th>Surface Area</th>
              <th>Unit</th>
              <th>Ownership</th>
              <th>Soil Type</th>
            </tr>

           </table>
          </div>
        </div>
      </div>        
    </div>
  </div>
</div>

<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-table.js"></script>

<script type="text/javascript">

  var $table = $('#table');
         $table.bootstrapTable({
            url: 'php/list-farmers.php',
            search: true,
            pagination: true,
            buttonsClass: 'primary',
            showFooter: false,
            minimumCountColumns: 5,
            columns: [{
                field: 'num',
                title: '#',
                sortable: true,
            },{
                field: 'landID',
                title: 'ID',
                sortable: true,
            },{
                field: 'location',
                title: 'Location',
                sortable: true,
            },{
                field: 'surfaceArea',
                title: 'Surface Area',
                sortable: true,

            },{
                field: 'surfaceAreaUnit',
                title: 'Unit',
                sortable: true,

            },{
                field: 'ownership',
                title: 'Ownership',
                sortable: true,

            },{
                field: 'soiltype',
                title: 'Soil Type',
                sortable: true,                
            }],

         });

</script>

我的php文件,如果它有帮助:

 <?php 

      header('Content-Type: application/json');

  include 'dbconnect.php';

    $sqltran = mysqli_query($con, "SELECT * FROM land where farmerID = 8")or 
      die(mysqli_error($con));
    $arrVal = array();



     $i=1;
    while ($rowList = mysqli_fetch_array($sqltran)) {

            $name = array(
                'num' => $i,
                'landID'=>$rowList['landID'],
                'location'=> $rowList['location'],
                'surfaceArea'=> $rowList['surfaceArea'],
                'surfaceAreaUnit'=> $rowList['surfaceAreaUnit'],
                'ownership'=> $rowList['ownership'],
                'soiltype'=> $rowList['soiltype']
              );    



             array_push($arrVal, $name); 
      $i++;     
    }
       echo  json_encode($arrVal); 

    mysqli_close($con);
    ?>   

0 个答案:

没有答案