Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo Angular 2 Grid Filter not available

I am using the Kendo Grid with Angular 2 using this http://www.telerik.com/kendo-angular-ui/components/grid/data-binding/ tutorial but I didn't find filtering in the grid. How can I filter my Kendo Grid with Angular 2?

like image 680
Prasanjeet Debnath Avatar asked Oct 07 '16 15:10

Prasanjeet Debnath


3 Answers

I created this plunker where you can filter your grid by product Name. It's a very basic example:

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

import {
  GridDataResult,
  SortDescriptor,
  orderBy
} from '@progress/kendo-angular-grid';

@Component({
  selector: 'my-app',
  template: `
      <input type="text" [(ngModel)]="filter" (ngModelChange)="change()">
      <kendo-grid
          [data]="gridView"
          [sortable]="{ mode: 'multiple' }"
          [sort]="sort"
          (sortChange)="sortChange($event)"
        >
        <kendo-grid-column field="ProductID" title="Product ID" width="120">
        </kendo-grid-column>
        <kendo-grid-column field="ProductName" title="Product Name">
        </kendo-grid-column>
        <kendo-grid-column field="UnitPrice" title="Unit Price" width="230">
        </kendo-grid-column>
      </kendo-grid>
  `
})
export class AppComponent {
    private filter: string;
    private sort: SortDescriptor[] = [];
    private gridView: GridDataResult;
    private products: any[] = [
      {
        "ProductID": 1,
        "ProductName": "Chai",
        "UnitPrice": 18.0000,
        "Discontinued": false
    },
       {
        "ProductID": 3,
        "ProductName": "Chai",
        "UnitPrice": 122.0000,
        "Discontinued": true
    }
                               ,{
        "ProductID": 2,
        "ProductName": "Chang",
        "UnitPrice": 19.0000,
        "Discontinued": false
    }];

    constructor() {
        this.loadProducts();
    }

    protected sortChange(sort: SortDescriptor[]): void {
        this.sort = sort;
        this.loadProducts();
    }

    private loadProducts(prods): void {
      const products = prods || this.products;
        this.gridView = {
            data: orderBy(products, this.sort),
            total: products.length
        };
    }

   private change(){
      this.loadProducts(this.products.filter(product => product.ProductName === this.filter));
   }

}
like image 89
Fabio Antunes Avatar answered Oct 21 '22 02:10

Fabio Antunes


Filters are not available in current Beta.0 version of kendo-angular2-grid.

At present, you can use limited API which are listed here

Issue is already reported on telerik's kendo-angular2. Refer this

Comment from Telerik member on this filter issue-

We don't have a concrete timeline for the grid filtering feature. There are a number of prerequisites of this feature, the most significant one being the date pickers. You can review our roadmap for further details - http://www.telerik.com/kendo-angular-ui/roadmap/

This idea is already posted on newly opened feedback portal Refer this

like image 5
Sanket Avatar answered Oct 21 '22 01:10

Sanket


I was just checking possible ways to enable filter in Kendo Angular 2 Grid and found that Telerik has enabled it. Please check following link.

http://www.telerik.com/kendo-angular-ui/components/grid/filtering/

like image 5
Deepp Avatar answered Oct 21 '22 02:10

Deepp