New Metronic Docs!Added Integration Docs with Starter Kits Apps for Laravel, Laravel Livewire, Angular, Vue, Symfony, Blazor Server, Django & Flask & more
Browse Docs

How to Pass Custom Parameters to Server-Side KTDataTable Requests


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 ?


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


FM WhatsApp is a modified version of the original WhatsApp, created by Fouad Mokdad, that offers advanced privacy options and full customization features. Unlike the official app, FM WhatsApp lets you hide your online status, blue ticks, typing indicator, and even prevent others from deleting messages. It also allows you to apply custom themes, change fonts and icons, and lock specific chats without using a third-party app. Since it's not on the Play Store, download FM WhatsApp from fmwhsapp to get the latest safe version.



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


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(