Skip to main content

Kendo UI Angular 2 Grid Filter [How To]

“How To Use Kendo UI Grid with Angular 2”?

The Kendo UI Grid is used to displays data in a tabular format and provides a full configurations options and the following example of Kendo Grid as given below,

Stayed Informed – Live PLUNKER Demo Link
Stayed Informed – Angular 2 Tutorials and Examples

Example as Source code as,

Angular 2 Component source as,

import { Component } from '@angular/core';
import { products } from './products';

@Component({
    selector: 'my-app',
    template: `
        <kendo-grid [data]="gridData" [height]="370">
            <kendo-grid-column field="ProductID" title="ID" width="40">
            </kendo-grid-column>
            <kendo-grid-column field="ProductName" title="Name" width="250">
            </kendo-grid-column>
            <kendo-grid-column field="Category.CategoryName" title="Category">
            </kendo-grid-column>
            <kendo-grid-column field="UnitPrice" title="Price" width="80">
            </kendo-grid-column>
            <kendo-grid-column field="UnitsInStock" title="In stock" width="80">
            </kendo-grid-column>
            <kendo-grid-column field="Discontinued" title="Discontinued" width="120">
                <template kendoGridCellTemplate let-dataItem>
                    <input type="checkbox" [checked]="dataItem.Discontinued" disabled/>
                </template>
            </kendo-grid-column>
        </kendo-grid>
    `
})
export class AppComponent {
    private gridData: any[] = products;
}

App Module source code as,

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { GridModule } from '@progress/kendo-angular-grid';

import { AppComponent }   from './app.component';

@NgModule({
  imports:      [ BrowserModule, GridModule ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})

export class AppModule { }

Sample Product list as,

export const sampleProducts = [{
    "ProductID" : 24,
    "ProductName" : "Guaraná Fantástica",
    "SupplierID" : 10,
    "CategoryID" : 1,
    "QuantityPerUnit" : "12 - 355 ml cans",
    "UnitPrice" : 4.5000,
    "UnitsInStock" : 20,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 0,
    "Discontinued" : true,
    "Category" : {
        "CategoryID" : 1,
        "CategoryName" : "Beverages",
        "Description" : "Soft drinks, coffees, teas, beers, and ales"
    }
}, {
    "ProductID" : 25,
    "ProductName" : "NuNuCa Nuß-Nougat-Creme",
    "SupplierID" : 11,
    "CategoryID" : 3,
    "QuantityPerUnit" : "20 - 450 g glasses",
    "UnitPrice" : 14.0000,
    "UnitsInStock" : 76,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 30,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 3,
        "CategoryName" : "Confections",
        "Description" : "Desserts, candies, and sweet breads"
    }
}, {
    "ProductID" : 26,
    "ProductName" : "Gumbär Gummibärchen",
    "SupplierID" : 11,
    "CategoryID" : 3,
    "QuantityPerUnit" : "100 - 250 g bags",
    "UnitPrice" : 31.2300,
    "UnitsInStock" : 15,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 0,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 3,
        "CategoryName" : "Confections",
        "Description" : "Desserts, candies, and sweet breads"
    }
}, {
    "ProductID" : 47,
    "ProductName" : "Zaanse koeken",
    "SupplierID" : 22,
    "CategoryID" : 3,
    "QuantityPerUnit" : "10 - 4 oz boxes",
    "UnitPrice" : 9.5000,
    "UnitsInStock" : 36,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 0,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 3,
        "CategoryName" : "Confections",
        "Description" : "Desserts, candies, and sweet breads"
    }
}, {
    "ProductID" : 48,
    "ProductName" : "Chocolade",
    "SupplierID" : 22,
    "CategoryID" : 3,
    "QuantityPerUnit" : "10 pkgs.",
    "UnitPrice" : 12.7500,
    "UnitsInStock" : 15,
    "UnitsOnOrder" : 70,
    "ReorderLevel" : 25,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 3,
        "CategoryName" : "Confections",
        "Description" : "Desserts, candies, and sweet breads"
    }
}, {
    "ProductID" : 49,
    "ProductName" : "Maxilaku",
    "SupplierID" : 23,
    "CategoryID" : 3,
    "QuantityPerUnit" : "24 - 50 g pkgs.",
    "UnitPrice" : 20.0000,
    "UnitsInStock" : 10,
    "UnitsOnOrder" : 60,
    "ReorderLevel" : 15,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 3,
        "CategoryName" : "Confections",
        "Description" : "Desserts, candies, and sweet breads"
    }
}, {
    "ProductID" : 50,
    "ProductName" : "Valkoinen suklaa",
    "SupplierID" : 23,
    "CategoryID" : 3,
    "QuantityPerUnit" : "12 - 100 g bars",
    "UnitPrice" : 16.2500,
    "UnitsInStock" : 65,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 30,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 3,
        "CategoryName" : "Confections",
        "Description" : "Desserts, candies, and sweet breads"
    }
}, {
    "ProductID" : 51,
    "ProductName" : "Manjimup Dried Apples",
    "SupplierID" : 24,
    "CategoryID" : 7,
    "QuantityPerUnit" : "50 - 300 g pkgs.",
    "UnitPrice" : 53.0000,
    "UnitsInStock" : 20,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 10,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 7,
        "CategoryName" : "Produce",
        "Description" : "Dried fruit and bean curd"
    }
}, {
    "ProductID" : 52,
    "ProductName" : "Filo Mix",
    "SupplierID" : 24,
    "CategoryID" : 5,
    "QuantityPerUnit" : "16 - 2 kg boxes",
    "UnitPrice" : 7.0000,
    "UnitsInStock" : 38,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 25,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 5,
        "CategoryName" : "Grains/Cereals",
        "Description" : "Breads, crackers, pasta, and cereal"
    }
}, {
    "ProductID" : 53,
    "ProductName" : "Perth Pasties",
    "SupplierID" : 24,
    "CategoryID" : 6,
    "QuantityPerUnit" : "48 pieces",
    "UnitPrice" : 32.8000,
    "UnitsInStock" : 0,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 0,
    "Discontinued" : true,
    "Category" : {
        "CategoryID" : 6,
        "CategoryName" : "Meat/Poultry",
        "Description" : "Prepared meats"
    }
}, {
    "ProductID" : 54,
    "ProductName" : "Tourtière",
    "SupplierID" : 25,
    "CategoryID" : 6,
    "QuantityPerUnit" : "16 pies",
    "UnitPrice" : 7.4500,
    "UnitsInStock" : 21,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 10,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 6,
        "CategoryName" : "Meat/Poultry",
        "Description" : "Prepared meats"
    }
}, {
    "ProductID" : 55,
    "ProductName" : "Pâté chinois",
    "SupplierID" : 25,
    "CategoryID" : 6,
    "QuantityPerUnit" : "24 boxes x 2 pies",
    "UnitPrice" : 24.0000,
    "UnitsInStock" : 115,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 20,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 6,
        "CategoryName" : "Meat/Poultry",
        "Description" : "Prepared meats"
    }
}, {
    "ProductID" : 56,
    "ProductName" : "Gnocchi di nonna Alice",
    "SupplierID" : 26,
    "CategoryID" : 5,
    "QuantityPerUnit" : "24 - 250 g pkgs.",
    "UnitPrice" : 38.0000,
    "UnitsInStock" : 21,
    "UnitsOnOrder" : 10,
    "ReorderLevel" : 30,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 5,
        "CategoryName" : "Grains/Cereals",
        "Description" : "Breads, crackers, pasta, and cereal"
    }
}, {
    "ProductID" : 57,
    "ProductName" : "Ravioli Angelo",
    "SupplierID" : 26,
    "CategoryID" : 5,
    "QuantityPerUnit" : "24 - 250 g pkgs.",
    "UnitPrice" : 19.5000,
    "UnitsInStock" : 36,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 20,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 5,
        "CategoryName" : "Grains/Cereals",
        "Description" : "Breads, crackers, pasta, and cereal"
    }
}, {
    "ProductID" : 58,
    "ProductName" : "Escargots de Bourgogne",
    "SupplierID" : 27,
    "CategoryID" : 8,
    "QuantityPerUnit" : "24 pieces",
    "UnitPrice" : 13.2500,
    "UnitsInStock" : 62,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 20,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 8,
        "CategoryName" : "Seafood",
        "Description" : "Seaweed and fish"
    }
}, {
    "ProductID" : 59,
    "ProductName" : "Raclette Courdavault",
    "SupplierID" : 28,
    "CategoryID" : 4,
    "QuantityPerUnit" : "5 kg pkg.",
    "UnitPrice" : 55.0000,
    "UnitsInStock" : 79,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 0,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 4,
        "CategoryName" : "Dairy Products",
        "Description" : "Cheeses"
    }
}, {
    "ProductID" : 60,
    "ProductName" : "Camembert Pierrot",
    "SupplierID" : 28,
    "CategoryID" : 4,
    "QuantityPerUnit" : "15 - 300 g rounds",
    "UnitPrice" : 34.0000,
    "UnitsInStock" : 19,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 0,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 4,
        "CategoryName" : "Dairy Products",
        "Description" : "Cheeses"
    }
}, {
    "ProductID" : 61,
    "ProductName" : "Sirop d'érable",
    "SupplierID" : 29,
    "CategoryID" : 2,
    "QuantityPerUnit" : "24 - 500 ml bottles",
    "UnitPrice" : 28.5000,
    "UnitsInStock" : 113,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 25,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 2,
        "CategoryName" : "Condiments",
        "Description" : "Sweet and savory sauces, relishes, spreads, and seasonings"
    }
}, {
    "ProductID" : 62,
    "ProductName" : "Tarte au sucre",
    "SupplierID" : 29,
    "CategoryID" : 3,
    "QuantityPerUnit" : "48 pies",
    "UnitPrice" : 49.3000,
    "UnitsInStock" : 17,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 0,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 3,
        "CategoryName" : "Confections",
        "Description" : "Desserts, candies, and sweet breads"
    }
}, {
    "ProductID" : 63,
    "ProductName" : "Vegie-spread",
    "SupplierID" : 7,
    "CategoryID" : 2,
    "QuantityPerUnit" : "15 - 625 g jars",
    "UnitPrice" : 43.9000,
    "UnitsInStock" : 24,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 5,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 2,
        "CategoryName" : "Condiments",
        "Description" : "Sweet and savory sauces, relishes, spreads, and seasonings"
    }
}, {
    "ProductID" : 64,
    "ProductName" : "Wimmers gute Semmelknödel",
    "SupplierID" : 12,
    "CategoryID" : 5,
    "QuantityPerUnit" : "20 bags x 4 pieces",
    "UnitPrice" : 33.2500,
    "UnitsInStock" : 22,
    "UnitsOnOrder" : 80,
    "ReorderLevel" : 30,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 5,
        "CategoryName" : "Grains/Cereals",
        "Description" : "Breads, crackers, pasta, and cereal"
    }
}, {
    "ProductID" : 65,
    "ProductName" : "Louisiana Fiery Hot Pepper Sauce",
    "SupplierID" : 2,
    "CategoryID" : 2,
    "QuantityPerUnit" : "32 - 8 oz bottles",
    "UnitPrice" : 21.0500,
    "UnitsInStock" : 76,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 0,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 2,
        "CategoryName" : "Condiments",
        "Description" : "Sweet and savory sauces, relishes, spreads, and seasonings"
    }
}, {
    "ProductID" : 66,
    "ProductName" : "Louisiana Hot Spiced Okra",
    "SupplierID" : 2,
    "CategoryID" : 2,
    "QuantityPerUnit" : "24 - 8 oz jars",
    "UnitPrice" : 17.0000,
    "UnitsInStock" : 4,
    "UnitsOnOrder" : 100,
    "ReorderLevel" : 20,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 2,
        "CategoryName" : "Condiments",
        "Description" : "Sweet and savory sauces, relishes, spreads, and seasonings"
    }
}, {
    "ProductID" : 67,
    "ProductName" : "Laughing Lumberjack Lager",
    "SupplierID" : 16,
    "CategoryID" : 1,
    "QuantityPerUnit" : "24 - 12 oz bottles",
    "UnitPrice" : 14.0000,
    "UnitsInStock" : 52,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 10,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 1,
        "CategoryName" : "Beverages",
        "Description" : "Soft drinks, coffees, teas, beers, and ales"
    }
}, {
    "ProductID" : 68,
    "ProductName" : "Scottish Longbreads",
    "SupplierID" : 8,
    "CategoryID" : 3,
    "QuantityPerUnit" : "10 boxes x 8 pieces",
    "UnitPrice" : 12.5000,
    "UnitsInStock" : 6,
    "UnitsOnOrder" : 10,
    "ReorderLevel" : 15,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 3,
        "CategoryName" : "Confections",
        "Description" : "Desserts, candies, and sweet breads"
    }
}, {
    "ProductID" : 69,
    "ProductName" : "Gudbrandsdalsost",
    "SupplierID" : 15,
    "CategoryID" : 4,
    "QuantityPerUnit" : "10 kg pkg.",
    "UnitPrice" : 36.0000,
    "UnitsInStock" : 26,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 15,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 4,
        "CategoryName" : "Dairy Products",
        "Description" : "Cheeses"
    }
}, {
    "ProductID" : 70,
    "ProductName" : "Outback Lager",
    "SupplierID" : 7,
    "CategoryID" : 1,
    "QuantityPerUnit" : "24 - 355 ml bottles",
    "UnitPrice" : 15.0000,
    "UnitsInStock" : 15,
    "UnitsOnOrder" : 10,
    "ReorderLevel" : 30,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 1,
        "CategoryName" : "Beverages",
        "Description" : "Soft drinks, coffees, teas, beers, and ales"
    }
}, {
    "ProductID" : 71,
    "ProductName" : "Flotemysost",
    "SupplierID" : 15,
    "CategoryID" : 4,
    "QuantityPerUnit" : "10 - 500 g pkgs.",
    "UnitPrice" : 21.5000,
    "UnitsInStock" : 26,
    "UnitsOnOrder" : 0,
    "ReorderLevel" : 0,
    "Discontinued" : false,
    "Category" : {
        "CategoryID" : 4,
        "CategoryName" : "Dairy Products",
        "Description" : "Cheeses"
    }
}];

HTML code for Kendo UI Grid with Angular 2 as,

<!DOCTYPE html>
<html>
  <head>
    <title>Kendo UI Grid with Angular 2</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="http://www.telerik.com/kendo-angular-ui/npm/node_modules//@progress/kendo-theme-default/dist/all.css" />
    <!-- 1. Load libraries -->
    <!-- Polyfill(s) for older browsers -->
    <script src="https://unpkg.com/core-js/client/shim.min.js"></script>

    <script src="https://unpkg.com/zone.js@0.6.23?main=browser"></script>
    <script src="https://unpkg.com/reflect-metadata@0.1.3"></script>
    <script src="https://unpkg.com/systemjs@0.19.27/dist/system.src.js"></script>

    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>

    <!-- Example-specific styles -->
    <style>
      html, body { overflow: hidden; }
      body { font-family: "RobotoRegular",Helvetica,Arial,sans-serif; font-size: 14px; margin: 0; }
      my-app { display: block; width: 100%; overflow: hidden; min-height: 80px; box-sizing: border-box; padding: 30px; }
      my-app > .k-loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
      .example-wrapper { min-height: 280px; }
      .example-wrapper p, .example-col p { margin: 0 0 10px; }
      .example-wrapper p:first-child, .example-col p:first-child { margin-top: 0; }
      .example-col { display: inline-block; vertical-align: top; padding-right: 20px; padding-bottom: 20px; }
      .example-config { margin: 0 0 20px; padding: 20px; background-color: rgba(0,0,0,.03); border: 1px solid rgba(0,0,0,.08); }
    </style>
  </head>

  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
    
  </body>
</html>

References,


I hope you are enjoying with this post! Please share with you friends. Thank you!!
By Anil Singh | Rating of this article (*****)

Popular posts from this blog

nullinjectorerror no provider for httpclient angular 17

In Angular 17 where the standalone true option is set by default, the app.config.ts file is generated in src/app/ and provideHttpClient(). We can be added to the list of providers in app.config.ts Step 1:   To provide HttpClient in a standalone app we could do this in the app.config.ts file, app.config.ts: import { ApplicationConfig } from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; import { provideClientHydration } from '@angular/platform-browser'; //This (provideHttpClient) will help us to resolve the issue  import {provideHttpClient} from '@angular/common/http'; export const appConfig: ApplicationConfig = {   providers: [ provideRouter(routes),  provideClientHydration(), provideHttpClient ()      ] }; The appConfig const is used in the main.ts file, see the code, main.ts : import { bootstrapApplication } from '@angular/platform-browser'; import { appConfig } from ...

List of Countries, Nationalities and their Code In Excel File

Download JSON file for this List - Click on JSON file    Countries List, Nationalities and Code Excel ID Country Country Code Nationality Person 1 UNITED KINGDOM GB British a Briton 2 ARGENTINA AR Argentinian an Argentinian 3 AUSTRALIA AU Australian an Australian 4 BAHAMAS BS Bahamian a Bahamian 5 BELGIUM BE Belgian a Belgian 6 BRAZIL BR Brazilian a Brazilian 7 CANADA CA Canadian a Canadian 8 CHINA CN Chinese a Chinese 9 COLOMBIA CO Colombian a Colombian 10 CUBA CU Cuban a Cuban 11 DOMINICAN REPUBLIC DO Dominican a Dominican 12 ECUADOR EC Ecuadorean an Ecuadorean 13 EL SALVA...

39 Best Object Oriented JavaScript Interview Questions and Answers

Most Popular 37 Key Questions for JavaScript Interviews. What is Object in JavaScript? What is the Prototype object in JavaScript and how it is used? What is "this"? What is its value? Explain why "self" is needed instead of "this". What is a Closure and why are they so useful to us? Explain how to write class methods vs. instance methods. Can you explain the difference between == and ===? Can you explain the difference between call and apply? Explain why Asynchronous code is important in JavaScript? Can you please tell me a story about JavaScript performance problems? Tell me your JavaScript Naming Convention? How do you define a class and its constructor? What is Hoisted in JavaScript? What is function overloadin...

25 Best Vue.js 2 Interview Questions and Answers

What Is Vue.js? The Vue.js is a progressive JavaScript framework and used to building the interactive user interfaces and also it’s focused on the view layer only (front end). The Vue.js is easy to integrate with other libraries and others existing projects. Vue.js is very popular for Single Page Applications developments. The Vue.js is lighter, smaller in size and so faster. It also supports the MVVM ( Model-View-ViewModel ) pattern. The Vue.js is supporting to multiple Components and libraries like - ü   Tables and data grids ü   Notifications ü   Loader ü   Calendar ü   Display time, date and age ü   Progress Bar ü   Tooltip ü   Overlay ü   Icons ü   Menu ü   Charts ü   Map ü   Pdf viewer ü   And so on The Vue.js was developed by “ Evan You ”, an Ex Google software engineer. The latest version is Vue.js 2. The Vue.js 2 is very similar to Angular because Evan ...

.NET Core MVC Interview Questions and Answers

» OOPs Interview Questions Object Oriented Programming (OOP) is a technique to think a real-world in terms of objects. This is essentially a design philosophy that uses a different set of programming languages such as C#... Posted In .NET » .Net Constructor Interview Questions A class constructor is a special member function of a class that is executed whenever we create new objects of that class. When a class or struct is created, its constructor is called. A constructor has exactly the same name as that of class and it does not have any return type… Posted In .NET » .NET Delegates Interview Questions Delegates are used to define callback methods and implement event handling, and they are declared using the "delegate" keyword. A delegate in C# is similar to function pointers of C++, but C# delegates are type safe… Posted In .NET » ASP.Net C# Interview Questions C# was developed by Microsoft and is used in essentially all of their products. It is mainly used for ...