angular / angular/components

Relax MatTableDataSource’s filter to be of type “{}”

オープン
#16,112 コメント 8 件 リアクション 6 件 担当者 0 名 GitHub で見る
area: material/table feature P3
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

#### Feature Description
Relax `MatTableDataSource.filter` to accept `{}`. Right now, it is restricted to `string`.
This would allow *much* easier custom filtering on multiple dimensions.

#### Use Case
When the filter is “only” a string, it makes it very difficult to “structurally” filter a table on multiple dimensions, even when customizing `filterPredicate` . Some recommendations on internet include:
- passing a JSon object, and parsing the JSon `filterPredicate`, for each and every row: http://nataliesmith.ca/blog/angular-material-filter-table
- everything in this bug thread: https://github.com/angular/components/issues/6178

While it works, it’s also a gratuitous workaround: It turns out that at no point does `MatTableDataSource` actually *require* filter to be a `string`: Whatever gets passed to `filter` just gets piped “as-is” to `filterPredicate`.

Here is a simple fork of “Table with filtering” that filters on different columns individually, where all I did was pass my complex object, while not respecting :
https://stackblitz.com/edit/table-filtering-multiple-filters-example?file=app/table-filtering-example.html
https://table-filtering-multiple-filters-example.stackblitz.io/

#### Caveats

It would still be up to the caller to make sure that their `filter` object is homogeneous with their `filterPredicate` object.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

MatTableDataSource.filter のエントリポイントから開始し、その値が filterPredicate にどのように渡されるかを調べます。既存の predicate のフローを維持しながら、パブリック型を {} を受け入れられるように更新し、構造化された多次元のフィルターオブジェクトが JSON 変換を必要とせずに機能することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
機能追加
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。