I am trying to use Metronic datatable however i am getting my data inside response['data']['data']. How do i set my table's data to this key and also i am getting nextPage, lastPage links from backend only through the api. Need to set those too.
i am using kt datatable if i get data in response['data'] then data does get set but below is
api response, i checked through the documentation and everything but there are no proper steps provided. please help
Hi Shrikanth Eligeti
We use Angular Datatables plugin from:
https://l-lin.github.io/angular-datatables
<table datatable [dtOptions]="dtOptions" class="row-border hover"></table>
dtOptions: DataTables.Settings = {
serverSide: true,
processing: true,
ajax: (params, callback) => {
const query = { page: params.start / params.length + 1, perPage: params.length };
this.http.get("your-api-url", { params: query }).subscribe((res: any) => {
callback({
recordsTotal: res.data.total,
recordsFiltered: res.data.total,
data: res.data.data,
});
});
},
columns: [
{ title: "ID", data: "id" },
{ title: "Name", data: "name" },
{ title: "Email", data: "email" },
],
};