Michał Balkowski
Michał Balkowski

Reputation: 21

How to refresh the ui-grid while leaving rendered filters intact?

I need to refresh the ui grid and leave the site and the filters intact. How can I do that?

Right now I'm using this inside a controller:

$scope.refresh = function () { $state.reload(); };

Upvotes: 1

Views: 115

Answers (1)

Michał Balkowski
Michał Balkowski

Reputation: 21

so my teammates were able to find an answer - all you have to do is reset the data source (reset the source to gridOptions.data):

$scope.refresh = function () {
    $scope.refreshGridData();
};

$scope.refreshGridData = function () {
    files.getfiles().success(handleSuccess).error(handleError);
}

and

angular.module('name.service', [
])

.factory('files', ['$http', function ($http) {
    return {
        getfiles: function () {
            var params = {
                ...
            };

            return $http({
                method: 'POST',
                url: '/url/to/api/function',
                data: JSON.stringify(params)
            });
        }
    }
}]);

Thanks for the help! :)

Upvotes: 1

Related Questions