Codeigniter Datatable在选择选择筛选器时不绘制我的列

Codeigniter Datatable在选择选择筛选器时不绘制我的列,codeigniter,Codeigniter,在这里,我根据从下拉列表中选择的值筛选Datatable。我的脚本代码如下所示 以下是dataTable配置的相关部分: 我根本无法让他们工作,也无法找出我做错了什么或为什么做错了。我受够了,有人能帮我吗 $(document).ready(function () { //datatables table = $('#productstable').DataTable({ "initComplete": function () {

在这里,我根据从下拉列表中选择的值筛选Datatable。我的脚本代码如下所示

以下是dataTable配置的相关部分:

我根本无法让他们工作,也无法找出我做错了什么或为什么做错了。我受够了,有人能帮我吗

$(document).ready(function () {
    //datatables
    table = $('#productstable').DataTable({
      "initComplete": function () {
        this.api().columns().every( function (i) {
          if (i == 2) {
            var selectId = "#selectbyname";
            var column = this;

            var select = $(selectId)
              .on( 'change', function () {
                var val = $.fn.dataTable.util.escapeRegex(
                  $(this).val()
                );

                column
                  .search(val ? '^' + val + '$' : '', true, false)
                  .draw();

              });
            column.data().unique().sort().each( function ( d, j ) {
              select.append( '<option value="'+d+'">'+d+'</option>' )
            });

          }
        });
      },
      "searching": true,
      "processing": true, //Feature control the processing indicator.
      "serverSide": true, //Feature control DataTables' server-side processing mode.
      "order": [], //Initial no order.
      responsive: true,
      <?php datatable_lang();?>

      // Load data for the table's content from an Ajax source
      "ajax": {
        "url": "<?php echo site_url('products/product_list')?>",
        "type": "POST",
        'data': {'<?=$this->security->get_csrf_token_name()?>': crsf_hash,'group': '<?=$this->input->get('group')?>'}
      },
      //Set column definition initialisation properties.
      "columnDefs": [
        {
          "targets": [0], //first column / numbering column
          "orderable": false, //set not orderable
        },
        {
          "targets": [2],
          "visible": false
        }
      ],
      dom: 'Blfrtip',lengthMenu: [10, 20, 50, 100, 200, 500],
      buttons: [
        {
          extend: 'excelHtml5',
          footer: true,
          exportOptions: {
            columns: [1, 2, 3, 4, 5, 6]
          }
        }
      ],
    });
  });