简体   繁体   English

Kendo Angular 2网格过滤器不可用

[英]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. 我正在使用这个http://www.telerik.com/kendo-angular-ui/components/grid/data-binding/教程使用带有Angular 2的Kendo Grid,但我没有在网格中找到过滤器。 How can I filter my Kendo Grid with Angular 2? 如何使用Angular 2过滤我的Kendo Grid?

Filters are not available in current Beta.0 version of kendo-angular2-grid. 当前Beta.0版本的kendo-angular2-grid中没有过滤器。

At present, you can use limited API which are listed here 目前,您可以使用此处列出的有限API

Issue is already reported on telerik's kendo-angular2. 已经在telerik的kendo-angular2上报告了问题。 Refer this 请参阅此

Comment from Telerik member on this filter issue- Telerik成员对此过滤器问题的评论 -

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/ 您可以查看我们的路线图以获取更多详细信息 - http://www.telerik.com/kendo-angular-ui/roadmap/

This idea is already posted on newly opened feedback portal Refer this 这种想法已经张贴在新开的反馈门户转寄此

I was just checking possible ways to enable filter in Kendo Angular 2 Grid and found that Telerik has enabled it. 我刚刚检查了在Kendo Angular 2 Grid中启用过滤器的可能方法,发现Telerik启用了它。 Please check following link. 请检查以下链接。

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

I created this plunker where you can filter your grid by product Name. 我创建了这个plunker ,您可以按产品名称过滤网格。 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));
   }

}

i added to the Fabio Antunes solution 我加入了Fabio Antunes解决方案
Import compileFilter from '@progress/kendo-data-query'; 从'@ progress / kendo-data-query'导入compileFilter;

and change the change() method to the following. 并将change()方法更改为以下内容。 This will allow you to filter by multiple columns. 这将允许您按多列过滤。 Again not exactly what i want, but this will do for now. 再次不完全是我想要的,但现在这样做。

const predicate = compileFilter({
            logic: "and",
            filters: [
                { field: "fildname1", operator: "contains", value: this.filterValue },
                { field: "fildname2", operator: "contains", value: this.filterValue },
                { field: "fildname3", operator: "eq", value: this.filterValue },
                { field: "fildname4", operator: "eq", value: this.filterValue },
            ]
        });
        const result = this.data.filter(predicate);
        this.gridView = {
            data: result,
            total: result.length
        };

Update on the Kendo filter - Very similar to Nonik's solution. 更新Kendo过滤器 - 非常类似于Nonik的解决方案。

Replace "compileFilter" with "filterBy". 将“compileFilter”替换为“filterBy”。 This is part of the dataquery set of helper functions. 这是辅助函数的dataquery集的一部分。

import { filterBy } from '@progress/kendo-data-query'

Kendo Data Query 剑道数据查询

For your information Kendo Grid has add filter feature in latest version. 为了您的信息,Kendo Grid在最新版本中添加了过滤功能。 Please look at their website. 请看他们的网站。

If you stll required some custome filter with kendo grid in angular 2 then look at here or search in google : Angular-2 + Kendo Grid Custom Filter 如果你需要在角度2中使用kendo网格的某些客户过滤器然后在这里查看或在谷歌搜索:Angular-2 + Kendo网格自定义过滤器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM