datatables - 具有固定列的数据表选择过滤器
问题描述
所以,我有一个左侧固定列的 DataTable,但想添加一个 Select like 过滤器,数据表不支持该过滤器。
我创建了选择过滤器,它在没有固定列的情况下工作得很好,因为它从原始表中过滤。问题是当我修复左列时,它不会将过滤器应用于克隆表
我尝试在克隆表中添加和“id”,然后也将过滤器应用到其中,但它不起作用
如图所示,它应用的过滤器“Externas”应该只显示橙色行,但固定列显示每一行
这是我的选择
<select id="filtrarTipo" onclick="filtradoTipo(); filtradoTipoC();">
<option value="" selected disabled>Seleccione</option>
<option value="">Todas</option>
<option value="Interna">Interna</option>
<option value="Externa">Externa</option>
</select>
还有我的jQuery
function filtradoTipo() {
// Declare variables
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("filtrarTipo");
filter = input.value.toUpperCase();
table = document.getElementById("dtBecas");
tr = table.getElementsByTagName("tr");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[4];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
解决方案
推荐阅读
- reactjs - 创建我的第一个反应应用程序时出现一些错误?
- java - 以 arraylist 或列表的形式从 firebase 存储中检索图像,然后将其发送到 firestore,稍后可以检索该图像以填充多个 img
- eclipse - 如何将变量添加到 Eclipse 项目?
- r - 将函数调用向量折叠成一行,用 & 分隔每个调用,使用替代和归约?
- java - 为什么设置
有时打印排序值,有时不打印? - javascript - WEBHID API:Inputreport 不使用条码扫描器触发
- c# - 是否可以通过编程方式禁用来自 HttpSys 的日志?
- git - 在 GitLab 存储迁移到散列后修复子模块 url 位置
- dart - 在 Dart null 安全之后如何对 null 值进行多重检查?
- visual-studio-code - 如何修复在 VScode 上找不到的“stdio.h”文件