我正在使用带有Ang DataTable
的asp.net WebApi。
查看:
<table class="table table-striped table-hover table-bordered dt-bootstrap no-footer" id="tabla_catalogos" role="grid" aria-describedby="sample_editable_1_info">
<thead>
<tr>
<th class="hidden"></th>
<th style="width: 200px;"> Codigo </th>
<th> Nombre </th>
</tr>
</thead>
<tbody></tbody>
</table>
角度控制:
$scope.filtro = function (selected) {
apiService.get("../../api/Catalogo/GetCatalogoRegistro/" + selected.ID);
}
这里我得到了值(我收到5个值)但是对于dataTable我只需要Codigo
和Nombre
,如果我单独测试它,我会毫无问题地收到参数。
所以现在我将它用于数据表的url参数
数据表:
$('#tabla_catalogos').DataTable({
searching: true,
dom: 'ftpB',
buttons: [
'excelHtml5', 'csv', 'print'
],
paging: true,
select: {
style: 'single'
},
info: false,
ordering: true,
"processing": true,
ajax: {
method: 'GET',
url: $scope.filtro = function (selected) {
apiService.get("../../api/Catalogo/GetCatalogoRegistro/" + selected.ID);
},
dataSrc: '',
beforeSend: function (request) {
request.setRequestHeader("Version", $scope.usuario.Version);
request.setRequestHeader("Origen", 'Web');
}
},
columns: [
{ data: 'Codigo' },
{ data: 'Nombre' },
],
pageLength: 10
, language: {
"emptyTable": "No se encontraron registros",
"zeroRecords": "No encontraron coincidencias",
"search": "Buscar: "
}
});
但在Chrome控制台中,我收到此错误:
未找到404: