Similarly to the advanced sorting features, sometimes the default filter on a string property
is not what you need. When this is the case you can write your own filter, with fully
custom template and controller, and both wrap it in and pass it to a
<clr-dg-filter>
component in your column declaration.
This can be done whether or not your column is declared as a
clrDgField
, and will always take precedence over it if it is.
The filter you provide to the <clr-dg-filter>
component
needs to implement the ClrDatagridFilterInterface
interface provided by Clarity:
There are several ways to pass your filter to the
<clr-dg-filter>
component:
[clrDgFilter]
input to pass your filter
instance:
DatagridFilter
parent in its constructor so
that it can register itself:
In our example, we can create "color picker" filter, rather than have to search by color name.
By default, filtering searches the original model value for matches. In cases where you format the text for display (such as using a pipe), you may want to create a custom filter to handle searching the formatted text. Otherwise, the results you see may not be filtered in the way you expect.
In the example above you will need to go with custom filters that will take into account the data that the user sees is the same that he is searching into.
You can use a preset filter on columns to initialize the data grid to a specific filtered state.
[(clrFilterValue)]
can be pre-set.