it feels very powerful to use datatables, for the first time, but I can"t figure out how to use it.
now pass parameters to the backend with fnServerData, which will all become object
my datatables is configured as
datatable() {
$("-sharpexample1").dataTable({
"paging": true,
"bProcessing": true,
"searching": true,
"bServerSide": true,
"fnServerData" : function(sSource, aDataSet, fnCallback) {
$.ajax({
"dataType" : "json",
"type" : "GET",
"headers":{"Authorization": token},
"url" : "http://192.168.2.47:8803/api/goods/manager",
"data" : aDataSet,
"success" : res=>{
console.log(res.data.goods.data);
fnCallback(res.data.goods.data);
}
});
},
"ordering": true,
// "info": true,
"autoWidth": true,
"bLengthChange": false,
"iDisplayLength": 20,
"bSort": true,
"oLanguage": {
"sProcessing": "...",
"sLengthMenu": " _MENU_ ",
"sZeroRecords": "",
"sInfo": " _START_ _END_ _TOTAL_ ",
"sInfoEmpty": "",
"sInfoFiltered": " _MAX_ ",
"sInfoPostFix": "",
"sSearch": "",
"sUrl": "",
"oPaginate": {
"sFirst": "",
"sPrevious": "",
"sNext": "",
"sLast": ""
}
},
"aoColumns": [
{
"name": "index"
}, {
"name": "image",
bSortable: false,
bSearchable: false
}, {
"name": "name",
bSortable: false
}, {
"name": "price",
bSortable: false
}, {
"name": "stock",
bSearchable: false
}, {
"name": "salesVolume",
bSearchable: false
}, {
"name": "updateAt"
}, {
"name": "btnBox",
bSortable: false,
bSearchable: false
}
],
})
},
do not understand how to do this, solve the problem.