Jquery datatable дает ошибку «Запрошен неизвестный параметр« 0 »из источника данных для строки 0» - PullRequest
0 голосов
/ 05 августа 2020

Я создаю формат json для jquery datatable, используя jquery, но выдает ошибку «Предупреждение DataTables (table id = 'compare'): запрошенный неизвестный параметр '0' из источника данных для строки 0» Я уже прочитал https://datatables.net/manual/tech-notes/4

мой Html -

            <div class="row wrap blocks" id="table1" >
            <div class="col-1"></div> 
            <div class="col-10 wrap-inner d-flex align-items-center">
                <table id="div_compare" class="dtables">
                    <thead>
                        <tr>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>

, а мой jquery код -

var compare =  $('#div_compare').DataTable({
scrollX: true,
bPaginate: false,
pageLength: 15,
bLengthChange: false,
bFilter: true,
bSort: true,
bInfo: false,
bOrdering: true,
bAutoWidth: false,
pageResize: true,
lengthChange: false,
dom: 'lrtip',
columns: [
    { data:'no',title: "No" },
    { data:'name',title: "Name" },
    { data:'time',title: "Best time"},
    { data:'Atime', title: "Atime"},
    { data:'Btime', title: "Btime"},
    { data:'Ctime', title: "Ctime"},
    { data:'Dtime', title: "Dtime"},
    { data:'lap',title: "Lap No" },
  ],
columnDefs: [
    { targets:'_all',className : 'dt-body-center'},
    { targets:  0, visible: true, width: 50 },
    { targets:  1, visible: true, width: 50 },
    { targets:  2, visible: true },
    { targets:  3, visible: true },
    { targets:  4, visible: true ,width: 100},
    { targets:  5, visible: true, width: 70 },
    { targets:  6, visible: true, width: 70 },
    { targets:  7, visible: true, width: 70 },
],});

getLaptime(query).done(function (response) {
   var comparedata = response.filter(x => x.order == 2)
   compare.row.add(comparedata).draw();
   compare.columns.adjust().draw();
}

    function getLaptime(data) {
      return doRefreshSession().then(function (headers) {
      return $.ajax({
          url: 'https://URL/laptime/comparelaptime',
          type: 'GET',
          data: data,
          headers: headers
      });
  });
}

Может ли кто-нибудь помочь мне решить эту проблему?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...