Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Select值筛选jQuery数据表_Javascript_Jquery_Datatables - Fatal编程技术网

Javascript 使用Select值筛选jQuery数据表

Javascript 使用Select值筛选jQuery数据表,javascript,jquery,datatables,Javascript,Jquery,Datatables,我有一个用于DataTables的简单表: <table class="table table-hover nowrap data-table" style="width:100%"> <thead> <tr> <th>Date</th> <th style="displaynone;">Type</th> </tr> </thead>

我有一个用于DataTables的简单表:

<table class="table table-hover nowrap data-table" style="width:100%">
  <thead>
    <tr>
      <th>Date</th>
      <th style="displaynone;">Type</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>12.12.2019</td>
      <td style="displaynone;">computer</td>
    </tr>
  </tbody>
</table>
但我不知道如何实现这一点。该表由PHP而不是通过Ajax调用填充数据

我已经将在JS函数中创建数据表的工作外包给了其他人:

var dataTable;
var dataTables = [];
function make_dataTable() {
    jQuery('table.data-table').each(function() {
            dataTable = jQuery(this).DataTable({
                responsive: false,
                pageLength: 25,
                autoWidth: true,
                lengthChange: false,
                language: { "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json" }
            });
            if (jQuery('table.data-table').length > 0) {
                new jQuery.fn.dataTable.FixedHeader( dataTable );
            }
            dataTables.push(dataTable);
        });
}

function dataTables_destroy() {
    for (var i=0; i<dataTables.length; i++) {
        dataTables[i].destroy();
    }
}

make_dataTable();

你有没有考虑过这方面的问题?这是否回答了你的问题?不,我是这样试的:但是什么也没发生,没有错误,也没有排序。谢谢你的“踢”屁股。我能修好它。我将编辑我的问题并发布答案。再次感谢你。我很高兴你解决了你的问题。不要将答案作为问题的一部分添加,你应该将答案作为单独的答案发布(在“你的答案”部分)。更一般地说,我们欢迎你回答自己的问题——如果你愿意,你甚至可以接受自己的答案。你有没有注意到这一点?这是否回答了你的问题?不,我是这样试的:但是什么也没发生,没有错误,也没有排序。谢谢你的“踢”屁股。我能修好它。我将编辑我的问题并发布答案。再次感谢你。我很高兴你解决了你的问题。不要将答案作为问题的一部分添加,你应该将答案作为单独的答案发布(在“你的答案”部分)。更一般地说,欢迎你回答自己的问题——如果你愿意,你甚至可以接受自己的答案。
var dataTable;
var dataTables = [];
function make_dataTable() {
    jQuery('table.data-table').each(function() {
            dataTable = jQuery(this).DataTable({
                responsive: false,
                pageLength: 25,
                autoWidth: true,
                lengthChange: false,
                language: { "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json" }
            });
            if (jQuery('table.data-table').length > 0) {
                new jQuery.fn.dataTable.FixedHeader( dataTable );
            }
            dataTables.push(dataTable);
        });
}

function dataTables_destroy() {
    for (var i=0; i<dataTables.length; i++) {
        dataTables[i].destroy();
    }
}

make_dataTable();
var NRequest = $('#newRequest').DataTable({
  responsive: false,
  pageLength: 25,
  autoWidth: true,
  colReorder: true,
  lengthChange: false,
  columnDefs: [
    { type: "de_date", targets: 0 }
  ],
  order: [[ 0, "asc" ]],
  language: { "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json" }
});

$('#requestTypeNew').on('change', function(){
  const selVal = $( "#requestTypeNew" ).val();
  NRequest.column(1).search( selVal ).draw();
});