二張表的代碼(我用的插件,你們能夠去網上直接下載http://issues.wenzhixin.net.cn/bootstrap-table/):bootstrap
<div class="container" style="float: left;width:500px;height: 341px"> <div id="toolbar"> <button id="remove" class="btn btn-danger" disabled=""> <i class="glyphicon glyphicon-remove"></i> Delete </button> </div> <table id="table" data-toolbar="#toolbar" data-search="true" data-detail-formatter="detailFormatter" data-minimum-count-columns="2" data-show-pagination-switch="true" data-pagination="true" data-id-field="id" data-page-list="[10, 25, 50, 100, ALL]" data-show-footer="false" data-side-pagination="server" data-url="./system/Dealer_obtainMachAndName" data-response-handler="responseHandler"> </table> </div> <!-- 右邊聯動部分 --> <div class="container" style="float: left;width:500px"> <table id="tablelink" data-toolbar="#toolbar" data-detail-formatter="detailFormatter" data-minimum-count-columns="2" data-pagination="true" data-id-field="id" data-page-list="[10, 25, 50, 100, ALL]" data-show-footer="false" data-side-pagination="server" data-url="./system/Dealer_obtainAIllerMes" data-response-handler="responseHandler" data-query-params="getPatientId" </table> </div>
箭頭所指處是我新添加的函數(注意不是寫成這樣data-query-params="getPatientId()")ide
而後給第一張表添加行點擊事件:函數
$('#table').on('check.bs.table', function (e, row, $element) { // console.log(row, $element); //getPatientId(); $('#tablelink').bootstrapTable('refresh',{url: "./system/Dealer_obtainAIllerMes"} ); });
這裏添加到插件對應模塊:url
這樣每次點擊的時候 調用表2的refresh方法的同時而後把對應的ID傳過去,而後根據後臺傳過來的數據更新該表。spa