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

@Component({
    selector: 'my-app',
    template: `
        <kendo-grid 
            productsBinding
            [aggregateResult]="total"
            [aggregates]="aggregates"
            [pageSize]="10"
            [pageable]="true"
            [sortable]="true"
            [groupable]="{ showFooter: true }"
            style="height:600px">
         <kendo-grid-column field="ProductID" title="Product ID" width="120">
            <ng-template kendoGridGroupHeaderTemplatе>
            </ng-template>
        </kendo-grid-column>
        <kendo-grid-column field="ProductName" title="Product Name">
        </kendo-grid-column>
        <kendo-grid-column field="UnitPrice" title="Unit Price" width="230">
            <ng-template
                kendoGridGroupFooterTemplate
                    let-group="group"
                    let-aggregates>Sum: {{aggregates["UnitPrice"].sum}}</ng-template>
            <ng-template
                kendoGridFooterTemplate
                    let-column="column">Total {{column.title}}: {{total["UnitPrice"]?.sum}}</ng-template>
        </kendo-grid-column>
        <kendo-grid-column field="Discontinued" width="80">
            <ng-template kendoGridCellTemplate let-dataItem>
                <input type="checkbox" [checked]="dataItem.Discontinued" disabled/>
            </ng-template>
        </kendo-grid-column>
       </kendo-grid>
    `
})
export class AppComponent {
  public aggregates: any[] = [{field: 'UnitPrice', aggregate: 'sum'}];
  public total: any = {};
}

import { Directive, OnInit, OnDestroy, Input } from '@angular/core';
import { DataBindingDirective, GridComponent } from '@progress/kendo-angular-grid';
import { ProductsService } from './northwind.service';
import { Subscription } from 'rxjs/Subscription';
import { process, aggregateBy } from '@progress/kendo-data-query';

@Directive({
    selector: '[productsBinding]'
})
export class ProductsBindingDirective extends DataBindingDirective implements OnInit, OnDestroy {
    private serviceSubscription: Subscription;

    @Input() public aggregates: any[];
    @Input() public aggregateResult: any;
    
    constructor(private products: ProductsService, grid: GridComponent) {
        super(grid);
    }

    public ngOnInit(): void {
        this.serviceSubscription = this.products.subscribe((result) => {
            this.grid.data = process(result || [], this.state);
            Object.assign(this.aggregateResult, aggregateBy(result || [], this.aggregates));
        });

        super.ngOnInit();

        this.rebind(); 
    }

    public ngOnDestroy(): void {
        if (this.serviceSubscription) {
            this.serviceSubscription.unsubscribe();
        }

        super.ngOnDestroy();
    }
    
    public rebind(): void { 
      if (this.state.group) {
        this.state.group.map(group => group.aggregates = this.aggregates);
      }

      this.products.query(this.state);
    }
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpModule } from '@angular/http';

import { GridModule } from '@progress/kendo-angular-grid';

import { AppComponent }   from './app.component';
import { ProductsBindingDirective }   from './remote-binding.directive';
import { ProductsService }   from './northwind.service';

@NgModule({
  imports:      [ BrowserModule, BrowserAnimationsModule, GridModule, HttpModule ],
  declarations: [ AppComponent, ProductsBindingDirective ],
  providers:    [ ProductsService ],
  bootstrap:    [ AppComponent ]
})

export class AppModule { }
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './ng.module';

enableProdMode();

const platform = platformBrowserDynamic();
platform.bootstrapModule(AppModule);
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { GridDataResult } from '@progress/kendo-angular-grid';
import { toODataString, process } from '@progress/kendo-data-query';
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';


import 'rxjs/add/operator/map';

export abstract class NorthwindService extends BehaviorSubject<GridDataResult> {
    private BASE_URL: string = 'http://services.odata.org/V4/Northwind/Northwind.svc/';

    constructor(private http: Http, private tableName: string) {
        super(null);
    }

    public query(state: any): void {
        this.fetch(this.tableName, state)
            .subscribe(x => super.next(x));
    }

    private fetch(tableName: string, state: any): Observable<GridDataResult> {
        // const queryStr = `${toODataString(state)}&$count=true`;
        return this.http
            .get(`${this.BASE_URL}${tableName}`)
            .map(response => response.json())
            .map(response => {
              return response.value;
            });
    }
}

@Injectable()
export class ProductsService extends NorthwindService {
    constructor(http: Http) { super(http, "Products"); }

    public queryForCategory({ CategoryID }: { CategoryID: number }, state?: any): void {
        this.query(Object.assign({}, state, {
            filter: {
                filters: [{
                    field: "CategoryID", operator: "eq", value: CategoryID
                }],
                logic: "and"
            }
        }));
    }

    public queryForProductName(ProductName: string, state?: any): void {
        this.query(Object.assign({}, state, {
            filter: {
                filters: [{
                    field: "ProductName", operator: "contains", value: ProductName
                }],
                logic: "and"
            }
        }));
    }

}

@Injectable()
export class CategoriesService extends NorthwindService {
    constructor(http: Http) { super(http, "Categories"); }
}
<!DOCTYPE html>
<html>
  <head>
    <title>Angular 2 QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" 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.8?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>
      console.clear();
      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; align-content: flex-start; }
      .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); }
      .event-log { margin: 0; padding: 0; max-height: 100px; overflow-y: auto; list-style-type: none; border: 1px solid rgba(0,0,0,.08); background-color: #fff; }
      .event-log li {margin: 0; padding: .3em; line-height: 1.2em; border-bottom: 1px solid rgba(0,0,0,.08); }
      .event-log li:last-child { margin-bottom: -1px;}
    </style>
  </head>

  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
    
  </body>
</html>
(function (global) {
  var angularVersion = '4.1.2';

  System.config({
    // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
    transpiler: 'ts',
    typescriptOptions: {
      tsconfig: true
    },
    meta: {
      'typescript': {
        "exports": "ts"
      },
      '*.json': {
        loader: 'systemjs-json-plugin'
      }
    },
    paths: {
      // paths serve as alias
      'npm:': 'https://unpkg.com/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',
      'systemjs-json-plugin': 'npm:systemjs-plugin-json',
      '@progress': 'http://www.telerik.com/kendo-angular-ui/npm/node_modules/@progress',
      '@telerik': 'http://www.telerik.com/kendo-angular-ui/npm/node_modules/@telerik',
      'cldr-data': 'http://www.telerik.com/kendo-angular-ui/npm/node_modules/cldr-data',

      // angular bundles
      '@angular/animations': 'npm:@angular/animations@' + angularVersion +'/bundles/animations.umd.js',
      '@angular/animations/browser': 'npm:@angular/animations@' + angularVersion +'/bundles/animations-browser.umd.js',
      '@angular/core': 'npm:@angular/core@' + angularVersion +'/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common@' + angularVersion +'/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler@' + angularVersion +'/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser@' + angularVersion +'/bundles/platform-browser.umd.js',
      '@angular/platform-browser/animations': 'npm:@angular/platform-browser@' + angularVersion +'/bundles/platform-browser-animations.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@' + angularVersion +'/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http@' + angularVersion +'/bundles/http.umd.js',
      '@angular/http/testing': 'npm:@angular/http@' + angularVersion +'/bundles/http-testing.umd.js',
      '@angular/forms': 'npm:@angular/forms@' + angularVersion + '/bundles/forms.umd.js',
      '@angular/router': 'npm:@angular/router@' + angularVersion + '/bundles/router.umd.js',

      // other libraries
      'rxjs':                       'npm:rxjs',
      'hammerjs':                   'npm:hammerjs@2',
      'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
      'ts':                         'npm:plugin-typescript@5/lib/plugin.js',
      'typescript':                 'npm:typescript@2.2/lib/typescript.js'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      "@progress/kendo-angular-grid": {"main":"dist/cdn/js/kendo-angular-grid.js","defaultExtension":"js"},
      "@progress/kendo-data-query": {"main":"dist/cdn/js/kendo-data-query.js","defaultExtension":"js"},
      "@progress/kendo-drawing": {"main":"dist/es/main.js","defaultExtension":"js"},
      "@progress/kendo-file-saver": {"main":"dist/npm/main.js","defaultExtension":"js"},
      "@progress/kendo-angular-intl": {"main":"dist/cdn/js/kendo-angular-intl.js","defaultExtension":"js"},
      "@progress/kendo-angular-l10n": {"main":"dist/cdn/js/kendo-angular-l10n.js","defaultExtension":"js"},

      app: {
        main: './main.ts',
        defaultExtension: 'ts'
      },
      rxjs: {
        defaultExtension: 'js'
      },
      'angular2-in-memory-web-api': {
        main: './index.js',
        defaultExtension: 'js'
      }
    }
  });
})(this);
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  }
}