bootstraptable 获取所有页中的选中行
时间: 2024-06-09 21:11:40 浏览: 16
要获取所有页中的选中行,你可以使用`getData`方法来获取表格中所有的数据,然后遍历数据,找到选中的行。具体步骤如下:
1. 使用`getSelections`方法获取当前页中选中的行数据。
2. 使用`getData`方法获取表格中所有的数据。
3. 遍历所有的数据,对于每一行数据,判断是否在第一步中获取到的选中行数据中。
4. 如果是选中行数据,将其添加到一个数组中。
5. 最后,数组中就是所有页中选中的行数据。
示例代码如下:
```javascript
var selectedRows = [];
var allData = $('#table').bootstrapTable('getData');
var selectedData = $('#table').bootstrapTable('getSelections');
for (var i = 0; i < allData.length; i++) {
if (selectedData.indexOf(allData[i]) > -1) {
selectedRows.push(allData[i]);
}
}
console.log(selectedRows);
```
其中,`selectedRows`就是所有页中选中的行数据。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![mp4](https://img-home.csdnimg.cn/images/20210720083504.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)