简体   繁体   English

Bootstrap 表从选定行获取数据

[英]Bootstrap table get data from selected row

I have created an bootstrap table (see image )我创建了一个引导表(见图)

在此处输入图片说明

this table is populated by an mysql connection with php server side.该表由与 php 服务器端的 mysql 连接填充。

My problem is to get data from selected row in a table, i know I have to use function我的问题是从表中的选定行获取数据,我知道我必须使用函数

bootstraptable('getselections')可引导('获取选择')

But I receive this但我收到这个

getSelections: [object Object] getSelections: [对象对象]

intead of this而是这个

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

Please can you help me?请你能帮帮我吗?

Full code here完整代码在这里

<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>

Refer Bootstrap Table getSelections example请参阅Bootstrap 表 getSelections 示例

It uses JSON.stringfy function.它使用 JSON.stringfy 函数。 So you have to use as follow.所以你必须使用如下。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM