Bootstrap-table 获取选中行的内容,并转化成 json
格式。
$('#table').bootstrapTable({
url: '/user/all', cache: false,
search: true, showPaginationSwitch: true, showRefresh: true, showToggle: true,
pagination: true, sortable: true, striped: true, clickToSelect: true,
columns: [{
field: "state", checkbox: true //复选框
}, {
field: 'id', title: '序号', sortable: true,
}, {
...
}]
});
<script>
function resetPassword() {
//返回选择行的数据
json = JSON.stringify($("#table").bootstrapTable('getSelections'));
json1 = json.slice(1, -1);
json2 = jQuery.parseJSON(json1);
json3 = eval('(' + json1 + ')');
}
</script>
变量 | 类型 | 输出 |
---|---|---|
json | string | '[{...}]' -> [{...}] |
json1 | string | '{...}' -> {...} |
json2 | object | {...} -> {...} |
json3 | object | {...} -> {...} |
未测试多行