Search code examples
javascriptangularjsangular-ui-gridui-grid

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(); };


Solution

  • 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! :)