簡體   English   中英

Bootstrap 表從選定行獲取數據

[英]Bootstrap table get data from selected row

我創建了一個引導表(見圖)

在此處輸入圖片說明

該表由與 php 服務器端的 mysql 連接填充。

我的問題是從表中的選定行獲取數據,我知道我必須使用函數

可引導('獲取選擇')

但我收到這個

getSelections: [對象對象]

而是這個

getSelections: [{"Nation":"dad","Site":"-"}]

請你能幫幫我嗎?

完整代碼在這里

<div id="toolbar">
            <button id="button" class="btn btn-default">getSelections</button>
        </div>
<table id="table" data-click-to-select="true" 
                data-toggle="table"
               data-toolbar="#toolbar"
               data-height="600"
               data-click-to-select="true" 
               data-url="db_list.php"
               data-search="true"
               data-pagination="true"
               >
            <thead>
            <tr>
                <th data-field="num"  data-checkbox="true" >#</th>
                <th data-field="Nation">Nation</th>
                <th data-field="Site">Site</th>
            </tr>
            </thead>

               </table>

<script type="text/javascript">
    var $table = $('#table'),
        $button = $('#button');

    $(function () {
        $button.click(function () {
            alert('getSelections: ' +  $("#table").bootstrapTable('getSelections'));
        });
    });
</script>

請參閱Bootstrap 表 getSelections 示例

它使用 JSON.stringfy 函數。 所以你必須使用如下。

alert('getSelections: ' + JSON.stringify($("#table").bootstrapTable('getSelections')));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM