Open sali1982 opened 8 years ago
On the Table Server Side, you usually assign a callback to call anytime something change like sorting, pagination or filters.
This function as we now from the documentation should look like this one.
$scope.getResource = function (params, paramsObj) {
var urlApi = 'table.json?' + params;
return $http.get(urlApi).then(function (response) {
return {
'rows': response.data.rows,
'header': response.data.header,
'pagination': response.data.pagination,
'sortBy': response.data['sort-by'],
'sortOrder': response.data['sort-order']
}
});
}
You want control the exact moment $http.get
it's trigged.
$scope.getResource = function (params, paramsObj) {
return $scope.showModalToCheckIfProceed().then(function() {
var urlApi = 'table.json?' + params;
return $http.get(urlApi).then(function (response) {
return {
'rows': response.data.rows,
'header': response.data.header,
'pagination': response.data.pagination,
'sortBy': response.data['sort-by'],
'sortOrder': response.data['sort-order']
}
});
}, function () {
console.log('Nope this time!')
});
}
Not sure will work, but the idea is to return a Promise with your custom implementation. I'm going to make documentation about it, so see how do it.
Thanks for the question.
I have a question for you.
I am having a serverside table. I want to give a warning to user, before the action of sorting happens, that he has some unsaved changes. If he says proceed, I will do the sort, if not, I won't do it.
Is there any function I can bind to the table to triggers before each action, like sorting, paging so if it is confirmed by user continues the action?