Hi everyone,
I'm using the Metronic theme (bootsrap) with KTDataTable in a .NET 8 Core project. I have successfully implemented server-side pagination, but I'm having trouble passing custom parameters (e.g., idCompany and idWallet) to the backend.
I've tried to use the mapRequest configuration to override the body. her an example:
const dataTableOptions = {
apiEndpoint: apiUrl,
requestMethod: "POST",
mapRequest: {
body: (body) => {
console.log("Original Body:", body);
let newBody = {
...body,
idCompany: this.clienteSelezionato.id,
idWallet: this.idWalletSelezionato
};
return newBody;
}
},
No logs are printed.
Can you please help me ?
Hi Fabio Drago
Thank you for sharing your solution - it will definitely help others who might face the same issue.
Hello,
the mistake was in the mapRequest body porperty.
The correct way is:
const dataTableOptions = {
apiEndpoint: apiUrl,
requestMethod: "POST",
mapRequest: (query) => {
console.log("Original Query:", query); // Debug per verificare i dati iniziali
query.set('idCompany', this.clienteSelezionato.id);
query.set('idWallet', this.idWalletSelezionato);
console.log("Modified Query:", query); // Debug per verificare che i parametri siano stati aggiunti
return query;
},
Kind regards,
Fabio Drago