python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
No Record Found in Angularjs ng-grid ui-grid

no record found in angularjs ng-grid and ui-grid

Hello everyone, Today I am going to share a article about "no record found message"  in angularjs ng-grid and ui-grid etc.

The live demo go to link http://embed.plnkr.co/Jj5sfS/preview

In the below example, we are going to explain over ui-grid for "No Record Found Message" as given below.

The Reference files


The AngularJs code-sample

var app = angular.module('uigridApp', ['ui.grid', 'ui.grid.selection', 'ui.grid.exporter']);

 app.controller("uigridCtrl", function ($scope, $http) {
      $scope.getJSONData = function () {
                $http.get('JSONdata.json')
                     .success(function (data) {
                         $scope.users = data;
                     });
         };

            $scope.uiGridOptions = {
                data: 'users',
                columnDefs: [{
                    field: 'name'
                }, {
                    field: 'gender',
                }, {
                    field: 'company'
                }]
            };

            $scope.users = {
                "data": []
            };

            $scope.Clear = function () {
                $scope.users = {
                    "data": []
                }
            };
  });

The HTML code-sample

<div ng-app="uigridApp">
    <div ng-controller="uigridCtrl">
        <h1>In Angular UI Grid, Display No Records Found </h1>
        <div>
            <input type="button" style="color:red;" value="Click to Get Users" ng-click="getJSONData()" />
            <input type="button" style="color:red;" value="Clear Users" ng-click="Clear()" />
        </div>
        <h3>User List</h3>
        <div ui-grid="uiGridOptions" ui-grid-selection class="gridHeight">
            <div ng-if="users.data.length==0">
                <span style="color:red;">No Records Found.</span>
            </div>
        </div>
    </div>
</div>

The CSS code-sample

    .gridHeight {
        height: 30px;
    }

The Full Live demo code-sample

<html>
<head>
    <link rel="stylesheet" href="http://ui-grid.info/release/ui-grid-unstable.css" type="text/css">
    <style type="text/css">
        .gridHeight {
            height: 30px;
        }
    </style>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
    <script src="http://ui-grid.info/release/ui-grid-unstable.js"></script>
    <script>
        var app = angular.module('uigridApp', ['ui.grid', 'ui.grid.selection', 'ui.grid.exporter']);
        app.controller("uigridCtrl", function ($scope, $http) {
            $scope.getJSONData = function () {
                $http.get('JSONdata.json')
                     .success(function (data) {
                         $scope.users = data;
                     });
            };

            $scope.uiGridOptions = {
                data: 'users',
                columnDefs: [{
                    field: 'name'
                }, {
                    field: 'gender',
                }, {
                    field: 'company'
                }]
            };

            $scope.users = {
                "data": []
            };

            $scope.Clear = function () {
                $scope.users = {
                    "data": []
                }
            };
        });
    </script>
</head>
<body ng-app="uigridApp">
    <div ng-controller="uigridCtrl">
        <h1>In Angular UI Grid, Display No Records Found </h1>
        <div>
            <input type="button" style="color:red;" value="Click to Get Users" ng-click="getJSONData()" />
            <input type="button" style="color:red;" value="Clear Users" ng-click="Clear()" />
        </div>
        <h3>User List</h3>
        <div ui-grid="uiGridOptions" ui-grid-selection class="gridHeight">
            <div ng-if="users.data.length==0">
                <span style="color:red;">No Records Found.</span>
            </div>
        </div>
    </div>
</body>
</html>


In the below images, We see the no record found message when users data length is zero or null and after click on get users button get the data of users and bind the data in ui grid and display data. i.e.









ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions