I've tried the answers related to the question in stackoverflow. It did not work out.
I'm trying to do the server side pagination in UI-GRID. Just struck at export all data as csv.
Since, my data is large. On load ,i'm showing only 25 data. When page changes query will be passed and it returns the next 25 values from db.
Is there is any event that trigger on export all data as csv? So, that i can hit the controller and retrieve the values that are actually present.
Sample code on pagination:
gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
paginationOptions.pageNumber = newPage;
paginationOptions.pageSize = pageSize;
CommonService.getStudents("../login/loadValues",
paginationOptions)
.then(function(data) {
$scope.ListOption.data = data;
$scope.ListOption.totalItems = data[0].count;
});
});
In the same way, I need to trigger event on export all data as CSV. ??
Any suggestions will be appreciated.
Found an answer,partially.
$scope.ListOption.exporterAllDataFn=function(){
//service call
CommonService.getStudents("../login/loadValues",
paginationOptions)
.then(function(data) {
$scope.ListOption.data = data;
$scope.ListOption.totalItems = data[0].count;
});
}
When i click the "export all data as csv", 2 times the function is getting called.
Note: This happens only at the first time of page load. On 2nd time click , function is called one time.
Anyone can explain ?