Skip to content

There is no grid option to display a message if the grid is empty #2597

@msosa

Description

@msosa

Hey guys, so there doesn't seem to be an easy option to display a message in the event of an empty grid. I was able to use the directive below which I got from #496. But that seemed to have been closed because it was a 2.x problem. Do you think a functionality like this could be added?

    .directive('showEmptyMsg', function ($compile, $timeout) {
        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                var msg = (attrs.showEmptyMsg) ? attrs.showEmptyMsg : 'Nothing to display';
                var template = "<p ng-hide='data.length'><b>" + msg + "</b></p>";
                var tmpl = angular.element(template);
                $compile(tmpl)(scope);
                $timeout(function () {
                    element.find('.ui-grid-viewport').append(tmpl);
                }, 0);
            }
        };
    })

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions