微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

DataTables 选择带有固定列的过滤器

如何解决DataTables 选择带有固定列的过滤器

所以,我有一个左侧固定列的数据表,但想添加一个类似选择的过滤器,数据表不支持该过滤器。

我创建了选择过滤器,它在没有固定列的情况下工作得很好,因为它从原始表中过滤。问题是当我修复左列时,它不会将过滤器应用到克隆表中

我已经尝试将 'id' 添加到克隆表中,然后也将过滤器应用到其中,但它不起作用

如图所示,它应用的过滤器“外部”应该只显示橙色行,但固定列显示每一行

Fixed column not filtering

这是我的选择

<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";
        }
      }
    }
  }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。