Bootstrap Table Resizable 怎么使用
时间: 2023-06-19 16:06:02 浏览: 137
Bootstrap Table Resizable 是一个基于 Bootstrap Table 的插件,用于实现表格列的拖拽调整大小功能。使用步骤如下:
1. 引入 Bootstrap Table 和 Bootstrap Table Resizable 的 CSS 和 JS 文件:
```html
<link rel="stylesheet" href="path/to/bootstrap-table.min.css">
<link rel="stylesheet" href="path/to/bootstrap-table-resizable.css">
<script src="path/to/jquery.min.js"></script>
<script src="path/to/bootstrap-table.min.js"></script>
<script src="path/to/bootstrap-table-resizable.min.js"></script>
```
2. 在表格元素上添加 `data-resizable="true"` 属性,开启拖拽调整大小功能:
```html
<table id="myTable" data-resizable="true">
<thead>
<tr>
<th data-resizable="false">ID</th>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>张三</td>
<td>20</td>
<td>男</td>
</tr>
<tr>
<td>2</td>
<td>李四</td>
<td>22</td>
<td>女</td>
</tr>
</tbody>
</table>
```
在表头中,可以通过 `data-resizable="false"` 属性禁用列的拖拽调整大小功能。
3. 初始化 Bootstrap Table,并且调用 `resizable()` 方法启用插件:
```javascript
$(function() {
$('#myTable').bootstrapTable().resizable();
});
```
这样,就可以在表格中拖拽调整列的大小了。
阅读全文
相关推荐














