Closed AviShmueli closed 8 years ago
Hi,
See below ho to use the remote mode but i advise to use only search in remote mode because if you use sorting and pagination in remote mode the CSV export and group features work only on the current page and not all the results. In my enterprise application i only use search in remote and the performance of sorting and pagination are good.
A. Configuration
var datatableConfig = {
search:{
active:true,
url:'/api/books'
}
};
$scope.datatable = datatable(datatableConfig);
B. Server side call
//your object map in the html form
var bookForm : {
authorName:'king'
};
//search function call by submit button
$scope.search = function(){
$scope.datatable.search($scope.bookForm);
};
C. Server side execution
Your server side function need to return a specific JSON object to UDT.
{
data:[], //all the data do tou want display in UDT
recordsNumber:undefined //the number of all result not only the current page
};
2. Pagination
A. Configuration
```javascript
var datatableConfig = {
search:{
active:true,
url:'/api/books'
},
pagination:{
active:true,
mode:'remote' //default mode
},
};
$scope.datatable = datatable(datatableConfig);
B. Server Side Your server function that execute the search need to manage two parameters add by UDT when search :
var datatableConfig = {
search:{
active:true,
url:'/api/books'
},
pagination:{
active:true,
mode:'remote' //default mode
},
order:{
active:true,
mode:'remote' //default mode
},
};
$scope.datatable = datatable(datatableConfig);
B. Server Side Your server function that execute the search need to manage two parameters add by UDT when search :
I hope that help you to use UDT.
Regards, Guillaume
Very helpful. Thank you!
How do I pass the following value from client side to server side?
pageNumber : number of the page numberRecordsPerPage : how many result on one page
Just added: "search":{ "active":true, "url":'admin/alluser' }, "pagination" : {
"active":true,
"mode" : 'remote'
} Got the desired API call URL: http://localhost:9026/portal/admin/alluser?datatable=true&numberRecordsPerPage=10&pageNumber=2&paginationMode=remote
Hello,
Your configuration seem good, now you need to call the function search() in UDT. The function search can be link with a submit form button and you can pass the form (json object) to the search function.
$http.get(url(), { params: this.getParams(params), datatable: this }).success(function(data, status, headers, config) { config.datatable._setData(data.data, data.recordsNumber); that.computeDisplayResultTimeOut.then(function() { that.setSpinner(false); }); });
It seems that AngularJS1.6.4 is not supporting ".success".
I have changed this .success to .then : if (url) { this.setSpinner(true); var that = this; $http.get(url(), { params: this.getParams(params), datatable: this })/.success(function(data, status, headers, config) { config.datatable._setData(data.data, data.recordsNumber); that.computeDisplayResultTimeOut.then(function() { that.setSpinner(false); }); });/ .then(function (response) {
var data = response.data;
var status = response.status;
var statusText = response.statusText;
var headers = response.headers;
var config = response.config;
config.datatable._setData(data, data.recordsNumber);
that.computeDisplayResultTimeOut.then(function() {
that.setSpinner(false);
})
console.log(data);
});
Now working
Cool, I need to upgrade to angular 1.6. Best regards, Guillaume
Any estimated timeline? Depending on that I will keep 1.6.4 or downgrade to 1.5.8
No estimated timeline for the angularjs upgrade, i hope during the next 6 month.
Hi, Is there an example for use in server-side functionality such as search, filtering, sorting and pagination? In the demo and the Doc, there are examples just for "local" functionality, and I need them to work in "remote" mode. Thanks...