jQuery数据表-显示结果,但不为复选框分配值

时间:2018-09-06 12:04:33

标签: jquery ajax datatables

前一天出现了一个问题,该问题不会显示复选框,但是现在显示了该复选框,但是没有为该复选框的value属性分配值 根据行ID,它只是显示未定义

这是我的数据表jquery代码:

$(document).ready(function() {
$('#companylist').dataTable( {
   dom: '<lf> <t><ip><"clear">',
    ajax: {
    url: 'data/companylist-ajax.php',
    dataSrc: '',
  },

   bPaginate:true,
   scrollX: "100%",
   columnDefs: [ {
           orderable: false,
           className: 'select-checkbox',
           targets:   0
       } ],
       select: {
           style:    'os',
           selector: 'td:first-child'
       },
   order: [[ 0, "desc" ]],
   scrollCollapse: true,
   bAutoWidth: true,

    aLengthMenu: [ 10, 25, 50, 75, 100 ],
    select: true,
        "columns": [
          { data: null,
             render: function(data) {
             //return '<input type="checkbox" name="selectcompanyid">';
             return '<div class="custom-control custom-checkbox"><input type="checkbox" class="custom-control-input checkboxdt" id="tableDefaultCheck"'+ data[0]+ '" value="'+ data[0]+ '"></div>';
             //return '<input class="checkboxdt" type="checkbox" name="test" value="' + data[0] +'">';
          }
        },
            { "data": "name" },
            { "data": "regoffice_city" },
            { "data": "regoffice_country" },
            { "data": "is_customer" },
            { "data": "is_supplier" },
            { data: null,
               render: function(data) {
               return '<a class="" href="viewcompany.php?companyid=' + data[0] + '"><i class="far fa-fw fa-eye fa-lg"></i></a>&nbsp;&nbsp;<a class="" id="delcompanybtn" data-href="data/deletecompany.php?companyid=' + data[0] + '" data-toggle="modal" data-target="#confirm-delete" data-id="' + data[0] + '"><i class="fa fa-fw fa-trash   fa-lg"></i></a>';
            }

          }
        ]
    } );

} );

这是我的AJAX页面响应:

[{"company_id":"181","name":"TEST 118","regoffice_city":"","regoffice_country":"United Kingdom","is_customer":"0","is_supplier":"0"},{"company_id":"182","name":"TEST 119","regoffice_city":"","regoffice_country":"United Kingdom","is_customer":"0","is_supplier":"0"},{"company_id":"75","name":"TEST 12","regoffice_city":"","regoffice_country":"United Kingdom","is_customer":"0","is_supplier":"0"},{"company_id":"183","name":"TEST 120","regoffice_city":"","regoffice_country":"United Kingdom","is_customer":"0","is_supplier":"0"},{"company_id":"184","name":"TEST 121","regoffice_city":"","regoffice_country":"United Kingdom","is_customer":"0","is_supplier":"0"},{"company_id":"185","name":"TEST 122","regoffice_city":"","regoffice_country":"United Kingdom","is_customer":"0","is_supplier":"0"},{"company_id":"186","name":"TEST 123","regoffice_city":"","regoffice_country":"United Kingdom","is_customer":"0","is_supplier":"0"},{"company_id":"187","name":"TEST 124","regoffice_city":"","regoffice_country":"United Kingdom","is_customer":"0","is_supplier":"0"}]

感觉就像我现在正在转圈

0 个答案:

没有答案