Alterative to queryParam and respondHandler
Alterative to queryParam and respondHandler
yvan.dupre79
Posts: 1Questions: 0Answers: 0
Actually i try to migrate bootstrap datatable from
bootstrap-table.wenzhixin.net.cn/
Is there a way to mach parameter of datable sent to the server and do a mathing with the value received from the server?
With bootstrap table respondHandler and queryParams was used for that.
$("#carsTableResult").bootstrapTable({
url: getHostName() + "/cars/";
silent: true,
queryParamsType: "",
responseHandler: function (res) {
return {
rows: res.content,
total: res.totalElements,
pageNumber: res.number,
pageSize: res.size
};
},
queryParams: function (params) { //todo check if we need to put search here
return {
search: params.searchText,
page: params.pageNumber - 1,
size: params.pageSize,
sort: params.sortName + "," + params.sortOrder
};
}
});
This discussion has been closed.
Replies
Yes but in the long run it would be more efficient to change your sever side code to handle and provide what datatables expect.
Having said that, you can used the data attribute in the ajax call in data tables to convert what datatables provides to what your sever expects.
On the return, there are a couple of places where you can intercept the response, such as the dataFilter section, to convert what your server sends out to what datatables expects.
i try to do the same thing... what you mean by dataFilter don't see any function with this name
maybe like this