Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • 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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(