Javascript 引导表从所选行获取数据

Javascript 引导表从所选行获取数据,javascript,php,bootstrap-table,Javascript,Php,Bootstrap Table,我已经创建了一个引导表(见图) 此表由与php服务器端的mysql连接填充 我的问题是从表中选定的行获取数据,我知道我必须使用函数 bootstraptable('getselections') 但我收到了这个 getSelections:[对象] 不知道 getSelections:[{“国家”:“爸爸”,“站点”:“-“}] 你能帮我吗 完整代码在这里 <div id="toolbar"> <button id="button" class="bt

我已经创建了一个引导表(见图)

此表由与php服务器端的mysql连接填充

我的问题是从表中选定的行获取数据,我知道我必须使用函数

bootstraptable('getselections')

但我收到了这个

getSelections:[对象]

不知道

getSelections:[{“国家”:“爸爸”,“站点”:“-“}]

你能帮我吗

完整代码在这里

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

获取选择
#
国家
场地
var$table=$(“#table”),
$按钮=$(“#按钮”);
$(函数(){
$按钮。单击(函数(){
警报('getSelections:'+$(“#表”).bootstrapTable('getSelections');
});
});
请参阅

它使用JSON.stringfy函数。因此,您必须按如下方式使用

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

getSelections[0]为您提供了什么?由于您在警报中打印,因此它会给出这样的输出。只需执行
console.log('getSelections:',$(“#table”).bootstrapTable('getSelections'))
@SujataChanda我收到这个消息:getSelections:w.fn.init[table#table]抱歉,但我不会使用JSON作为数据url来填充我的表。如果我这样做,我会收到:'getSelections:{“0”:{“jQuery331073420158381058982:{“宽度”:600,“高度”:600,“showColumns”:true},“jQuery331073420158381058981”:{“hasDataAttrs”:true},“length”:1}`Um..请显示bootstrap-table.js文件的getSelections方法代码。`BootstrapTable.prototype.getSelections=function(){var that=this;返回$.grep(this.options.data,function(row){//fix#2424:from html with checkbox return row[that.header.stateField]==true;}`