I am using AJAX in ktdatatable and Spring MVC model.
How to get Paging information from the request in Controller?
Here my code.
I tried to use parameter map to get value from pagination info.
But there is nothing. How do I need to do?
### Javascript
datatable = $('#detail_datatable').KTDatatable({
// datasource definition
data: {
type: 'remote',
source: {
read: {
url: '/retrieveItemConfig',
data: {},
map: function(raw) {
// sample data mapping
var dataSet = raw;
if (typeof raw.data !== 'undefined') {
dataSet = raw.data;
}
return dataSet;
},
},
},
pageSize: 5, // display 20 records per page
serverPaging: true,
serverFiltering: false,
serverSorting: true,
saveState: false,
},
// layout definition
layout: {
scroll: false, // enable/disable datatable scroll both horizontal and vertical when needed.
footer: false, // display/hide footer
},
// column sorting
pagination: true,
toolbar: {
// toolbar placement can be at top or bottom or both top and bottom repeated
placement: ['bottom'],
// toolbar items
items: {
// pagination
pagination: {
// page size select
pageSizeSelect: [5, 10, 20, 30, 50, 999], // display dropdown to select pagination size. -1 is used for "ALl" option
},
},
},
search: {
input: $('#search_query_order'),
key: 'generalSearch'
},
// columns definition
columns: [...]
#### Spring controller
@RequestMapping(value = "/retrieveItemConfig" )
public List<ItemConfig> retrieveItemConfig(@RequestParam Map<String, String> parameters){
System.out.println(parameters);
return service.retrieveItemConfig();
}
Hi,
Please check our example KTDatatable online.
https://preview.keenthemes.com/keen/demo1/features/ktdatatable/base/data-ajax.html
You can see the parameters that are being sent from KTDatatable to the server using the Remote tab in the Devs tool.
https://ibb.co/qr0Prmn
https://ibb.co/dbt5BBj
Thanks