获取行数据
{
field: 'operate',
width: "150px",
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'test',
text: '获取行数据',
classname: 'btn btn-xs btn-success btn-click',
click: function (e, row) {
// 获取到此行所有数据
console.log(row);
}
}],
formatter: Table.api.formatter.operate
}
获取选中项数据
1、视图文件中增加获取选中项按钮,其中 btn-selected
用于绑定点击事件
<a class="btn btn-info btn-disabled disabled btn-selected" href="javascript:;"><i class="fa fa-leaf"></i> 获取选中项</a>
2、js文件中绑定点击事件
//获取选中项
$(document).on("click", ".btn-selected", function () {
// 获取选中项ids
console.log(JSON.stringify(Table.api.selectedids(table)));
// 获取选中项所有数据
console.log(JSON.stringify($("#table").bootstrapTable('getSelections')));
});