javascript - 在同一行中获取 Bootstrap Table 列标题和过滤器控件
问题描述
我有以下Bootstrap Table
。表中有些列有filter-control
,有些有title
。这两列都没有。title
具有 is的列sortable
。
如this fiddle所示,filter-control
andtitle
显示在不同的行中。我想在同一行显示两者。我怎样才能做到这一点?
HTML
<table id="table"></table>
JS
$('#table').bootstrapTable({
filterControl: true,
showSearchClearButton: true,
columns: [{
field: 'id',
title: 'Item ID',
sortable: true
}, {
field: 'name',
title: 'Item Name',
sortable: true
}, {
field: 'price',
// title: 'Item Price',
filterControl: 'select',
filterControlPlaceholder: 'Item Price'
}],
data: [{
id: 1,
name: 'Item 1',
price: '$1'
}, {
id: 2,
name: 'Item 2',
price: '$2'
}]
})
当前输出
解决方案
我找不到执行此操作的表或列选项,因此我创建了一些 jQuery,使表显示在同一行中。
在您的示例中:
$('[data-field=price]').find('.th-inner').append($('[data-field=price]').find('.filterControl'))
$('th').find('.fht-cell').remove()
第一行将过滤器控件移动到标题字段中,第二行删除了所有原始过滤器控件包装器,它们具有固定的高度并且会使表头保持过高。
推荐阅读
- java - Springboot Jpa 柱子位置扭曲
- scheme - 是为地图附加身份功能吗?
- testing - 使用 jest-dom 使用 Tailwind CSS 转换测试 React 组件的可见性
- mongodb - 如何将朋友的朋友添加到我的朋友列表中?
- google-colaboratory - 关于“在 Google colab 文本单元格中插入图片”的更多问题
- linux - 如何根据 .txt 文件 unix 中现有列的值添加新列
- javascript - JavaScript 如何解析查询
- java - 无法在测试单元中调用 JpaRepository
- javascript - 如何让codemirror处理双引号和单引号
- gitlab - 根据 Gitlab 中的前端或后端更改构建和部署