javascript - 引导表从选定行获取数据
问题描述
我创建了一个引导表(见图)
此表由与 php 服务器端的 mysql 连接填充。
我的问题是从表中的选定行中获取数据,我知道我必须使用函数
引导表('getselections')
但我收到这个
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>
解决方案
它使用 JSON.stringfy 函数。所以你必须使用如下。
alert('getSelections: ' + JSON.stringify($("#table").bootstrapTable('getSelections')));
推荐阅读
- bash - 如何将 $PATH 的制表符完成作为 bash 脚本中的参数?
- c++ - 合并排序 C++ 不排序
- javascript - 连接不同数组中具有相同属性的对象
- python - 尝试在 Python 中安装库时出错
- firebase - Flutter 为聊天消息添加时间
- node.js - 快递验证器自定义错误不起作用
- flutter - 使用 rxdart 处理具有 bloc 模式的 api 响应
- php - 获取未购买产品的用户
- sql - Azure SQL 超大规模中的跟踪标志
- python - 如何:在 ArchLinux / Raspbian / Volumio / Raspberry 上升级到 Python 3.8.5