DataTable(jQuery插件)不显示最后一列

DataTable(jQuery插件)不显示最后一列,jquery,datatables,Jquery,Datatables,我正在处理datatable,我的datatable并没有显示表中的最后一列。例如,如果我有30列,那么datatable不显示第30列。它只显示了第29列,尽管我通过ajax响应收到了完整的数据。 上图仅显示3列。但我们有4列。请看下图。。。 请参阅下面的所有代码 var table = $('#csv_as_dataTable').DataTable({ "colReorder": { fixedColumnsLeft: 1, fixed

我正在处理datatable,我的datatable并没有显示表中的最后一列。例如,如果我有30列,那么datatable不显示第30列。它只显示了第29列,尽管我通过ajax响应收到了完整的数据。

上图仅显示3列。但我们有4列。请看下图。。。

请参阅下面的所有代码

   var table  =  $('#csv_as_dataTable').DataTable({
    "colReorder": {
        fixedColumnsLeft: 1,
        fixedColumnsRight: 1,
      },
    "pagingType": "full_numbers",
     "scrollX": false,
     "colReorder": true,
     "iDisplayLength": 100,
     "aLengthMenu": [[100, 200, 500, 1000], [100, 200, 500, 1000]],
     "initComplete": function(settings, json) {
        $('#csv_as_dataTable').wrap("<div id='db_scroll'></div>");


        },
      //"responsive": true,
      "bProcessing": true,
      "oLanguage": {
        "sProcessing": "<div class='datatableNewProcessor'>Processing..</div>"
      },
      "aaSorting": [],
      "columns": JSON.parse(headersData),
      "bFilter": false,
      "bServerSide": true,
      "columnDefs": [{
        "targets": -1,
        "visible": false,
      }],
     "sAjaxSource": "/es_scripts/data_table_server.php",
     "fnServerData": function (sSource, aoData, fnCallback) {
      aoData.push({"name": "indexName", "value": indexName});
      aoData.push({"name": "indexType", "value": indexType});
      //getting the values form fields 
      var filersCount = $('input[name="filter_count"]').val();
        var filterJson = "";
        for (i = 1; i <= filersCount; i++) {
          if ($('#filter' + i).length == 0) {
            continue;
          }
          if ($('#fil_val' + i).val() == "") {
            continue;
          }
          var colname = $('#cols_list' + i).val();

          var operator = $('#op_list' + i).val();
          var required_val = $('#fil_val' + i).val();
          if (colname == '' || operator == '') {
            alert('Column name & operators are required to apply filter');
            return false;
          }
          filterJson += '{"colname":"' + colname.split(' ').join('_') + '", "operator":"' + operator + '", "required_val":"' + required_val + '"},';
        }
        filterJson = filterJson.replace(/,\s*$/, "");
        filterJson = "[" + filterJson + "]";
        aoData.push({"name": "filterJson", "value": filterJson});
        console.log("************filterjson**************");
        console.log(filterJson);
        console.log("***************************");

      //@ajax call to server
        $.ajax({
          "dataType": 'json',
          "type": "GET",
          "url": sSource,
          "data": aoData,
          "success": function (json) {
            //var json = '{"iDisplaying": 3,"iTotalDisplayRecords": 3,"iTotalRecords": 3,"aaData": [["Nixon","Architect","5421"],["Nixon1","Architect1","54211"],["Nixon2","Architect","5421"]]}';
            console.log("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
            //console.log(JSON.parse(json));
            console.log(json);
            console.log("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
            //fnCallback(JSON.parse(json));
            fnCallback(json);
          },
          "timeout": 30000,   // Optional if you want to handle timeouts (which you should)
          //"error": handleAjaxError // this sets up jQuery to give me errors.
        });

  /////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////
 },
var table=$('#csv_as_dataTable')。dataTable({
“colReorder”:{
固定柱长度:1,
固定柱右侧:1,
},
“pagingType”:“完整编号”,
“scrollX”:错误,
“colReorder”:正确,
“iDisplayLength”:100,
“阿伦图努”:[[1002005001000],[1002005001000],
“initComplete”:函数(设置,json){
$('#csv_as_dataTable')。换行(“”);
},
//“响应”:正确,
“bProcessing”:正确,
“语言”:{
“sProcessing”:“Processing…”
},
“aaSorting”:[],
“columns”:JSON.parse(headersData),
“bFilter”:错误,
“bServerSide”:正确,
“columnDefs”:[{
“目标”:-1,
“可见”:假,
}],
“sAjaxSource”:“/es_scripts/data_table_server.php”,
“fnServerData”:函数(sSource、aoData、fnServerData回调){
push({“name”:“indexName”,“value”:indexName});
推送({“名称”:“indexType”,“值”:indexType});
//获取表单字段中的值
var filersCount=$('input[name=“filter_count”]')。val();
var filterJson=“”;

因为(i=1;i我相信你的问题在这里,你隐藏了最后一列

"columnDefs": [{
        "targets": -1,
        "visible": false,
      }],
正如医生所说:

例如,targets:[-1,-2]将以最后一个和最后第二个为目标 表中的列


完整参考

我相信你的问题在这里,你正在隐藏最后一列

"columnDefs": [{
        "targets": -1,
        "visible": false,
      }],
正如医生所说:

例如,targets:[-1,-2]将以最后一个和最后第二个为目标 表中的列


完整参考

如果您不发布代码,我们如何帮助您?等等,我将发布代码…NikNik请查看上面的代码…如果您不发布代码,我们如何帮助您?等等,我将发布代码…NikNik请查看上面的代码。。。。