Dear,
I am using datatable, ajax for pagination, it is worked well but in my URL I have many param and I would like to remove some of them because I don't need it.
URL Example :
http://localhost:8080/rest/getProcess?draw=11&columns%5B0%5D%5Bdata%5D=id&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=false&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=id&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=false&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=processName&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=false&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=processParameterList&columns%5B3%5D%5Bname%5D=&columns%5B3%5D%5Bsearchable%5D=true&columns%5B3%5D%5Borderable%5D=false&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=exceptionMessage&columns%5B4%5D%5Bname%5D=&columns%5B4%5D%5Bsearchable%5D=true&columns%5B4%5D%5Borderable%5D=false&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B5%5D%5Bdata%5D=exceptionStacktrace&columns%5B5%5D%5Bname%5D=&columns%5B5%5D%5Bsearchable%5D=true&columns%5B5%5D%5Borderable%5D=false&columns%5B5%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B5%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B6%5D%5Bdata%5D=timestamp&columns%5B6%5D%5Bname%5D=&columns%5B6%5D%5Bsearchable%5D=true&columns%5B6%5D%5Borderable%5D=false&columns%5B6%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B6%5D%5Bsearch%5D%5Bregex%5D=false&start=0&length=10&search%5Bvalue%5D=&search%5Bregex%5D=false&_=1652958066336
It is so much but I just need 3 params
start
length
search
How can I resolve it ?
At the end I would like to get something lke
htttp://localhost:8080/rest/getProcess?size=1&length=10&search='ddd'
My code
var table = $('#workflowProcess').DataTable( {
processing: true,
serverSide: true,
"ordering": false,
"ajax": {
"type" : "GET",
"url": "rest/getProcess",
"dataSrc": function ( json ) {
return json["data"];
}
},
"columns": [
{ data: 'id' },
{ data: 'id' },
{ data: 'name' },
{ data: 'list' },
{ data: 'messs' },
{ data: 'timestamp' }
]
} );
Thanks
Answers
There is not an option to remove the parameters sent when using server side processing. See the SSP docs for details of the parameters. Looks like you are using a REST API. Can you send a POST request instead of a GET request?
EDIT: The other option is to turn off server side processing and manually provide those parameters via the
ajax.data
option. Similar to this example.Kevin
Oww good to know, thanks, yes I can send POST .. and using a POST, I can set param to send ?
Thanks
See my updated comment above. You will need to turn off server side processing and provide your own parameters.
Kevin
Ok thank you, right it is more simple ... but how can I get the current page, size of datatble pagination and pass it in param ?
If you turn off server side processing then Datatables will assume all the rows are in the client and will enable client side processing. If you need to use paged data with your REST API then you will need to implement your own paging buttons and search input. You can then use
ajax.reload()
when you want to perform searching or paging and send the parameters form your search and paging inputs.Kevin
Ok thank you so much, So I need to implement my own pagination .. thanks Kemin