我试图将使用 ajax 获得的一些数据渲染到数据表中,但似乎我丢失了一些东西,因为它显示错误: TypeError: c is undefined。
我读过这篇文章,数据表类型错误:c 未定义 https://stackoverflow.com/questions/29893207/datatables-typeerror-c-is-undefined,但给出的任何解决方案都没有解决我的问题。有人有一个想法可以帮助我吗?谢谢。
html代码:
<table id="itinerariDetailTable" class="table table-sm table-striped table-bordered" style="font-size: x-small;">
<thead class="thead-inverse">
<tr>
<th>Id</th>
<th>Codi</th>
<th>Descripció</th>
<th>Temporada</th>
<th>Districte</th>
<th>Barri</th>
<th>C. Treball</th>
<th>G. Servei</th>
<th>T. Servei</th>
<th>Máquina</th>
<th>Corretorn</th>
<th>Torn</th>
<th>Tipus Día</th>
<th>Equips</th>
<!-- <th>Jornades</th>
<th>Cost unitari</th>
<th>T. Itinerari</th>
<th>Escenario</th> -->
</tr>
</thead>
<tfoot>
<tr>
<th>Id</th>
<th>Codi</th>
<th>Descripció</th>
<th>Temporada</th>
<th>Districte</th>
<th>Barri</th>
<th>C. Treball</th>
<th>G. Servei</th>
<th>T. Servei</th>
<th>Máquina</th>
<th>Corretorn</th>
<th>Torn</th>
<th>Tipus Día</th>
<th>Equips</th>
<!-- <th>Jornades</th>
<th>Cost unitari</th>
<th>T. Itinerari</th>
<th>Escenario</th> -->
</tr>
</tfoot>
</table>
js code:
$('#itinerariDetailTable').DataTable( {
"processing": true,
"serverSide": true,
"ajax":{
"url":'/escenaris/selectById',
"type":'GET',
"data": function(d){
d.idEscenari = $('#idEscenari').val();
}
},
"order": [[ 0, "asc" ]],
"columns": [
{ "data": "idItinerari" },
{ "data": "codiItinerari" },
{ "data": "descripcio" },
{ "data": "temporada.codiTemporada" },
{ "data": "districte" },
{ "data": "barri" },
{ "data": "centreTreball" },
{ "data": "grupServei" },
{ "data": "tractamentRecursos" },
{ "data": "maquinaCombustible" },
{ "data": "corretorn" },
{ "data": "torn" },
{ "data": "tipusDia" },
{ "data": "nombreEquips" }
/*{ "data": "frequencia" },
{"data": "resultatItinerari.costUnitari", "defaultContent": "0" },
{ "data": "tipusItinerari.codiTipusItinerari" }/*,
{ "data": "escenari.idEscenari" } */
]
});