Reputation: 11
I have created an bootstrap table (see image )
this table is populated by an mysql connection with php server side.
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]
intead of this
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>
Upvotes: 1
Views: 16510
Reputation: 11
Refer Bootstrap Table getSelections example
It uses JSON.stringfy function. So you have to use as follow.
alert('getSelections: ' + JSON.stringify($("#table").bootstrapTable('getSelections')));
Upvotes: 1