Important
You are browsing the documentation for version 4.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.
See our Release Process documentation for more information on the currently supported and upcoming releases.
Grid Extension¶
The FilterBundle provides an extension for datagrid with ORM and Search datasources. Filters could be added to the datagrid in the datagrids.yml file for a specified datagrid under the filters node. Definition of any filter requires option data_name that should be referenced to column in the query and type (filter type).
For example:
1 SOME_DATAGRID:
2 source:
3 type: orm
4 query:
5 select:
6 - g.id
7 - g.label
8 from:
9 - { table: OroContactBundle:Group, alias: g }
10
11 filters:
12 columns:
13 SOME_FITLER_NAME: # uses for query param, and for setting default filters
14 type: string # Filter type, list of available types described below
15 data_name: g.id
16 enabled: true|false #whether filter enabled or not. If filter is not enabled it will not be displayed in filter list but will be accessible in filter management.
17 disabled: true|false #If filter is disabled it will not be displayed in filter list and will not be available in filter management.
18 visible: true|false #If set to "false" - filter will not be displayed anywhere in UI. However, one can still set filter's value in backend or via url in frontend
19 force_like: true|false #Different search engines uses different methods for text search. When `force_like` is set to true, text-based filters will use simple `LIKE %%` OR `NOT LIKE %%`statement which depends on a chosen operator
20 min_length: integer #In case of text-based filters this option introduce possibility to ignore filters with less characters then specified. Validation message will also appear
21 divisor: number #In case of number-based filters this option will filter values rendered with datagrid divisor option.
22 case_insensitive: true|false #When set to 'true' text search filter will be case insensitive [Postgres only].
23 value_conversion: string #Callback for text search filter used for converting value passed to a query.
Default Values¶
String Filter¶
1 filters:
2 columns:
3 fieldName:
4 type: string
5 data_name: priorityLabel
6 case_insensitive: true
7 default:
8 fieldName: { value: 'someText', type: 'Oro\Bundle\FilterBundle\Form\Type\Filter\TextFilterType::TYPE_CONTAINS' }
Choice Filter¶
1 filters:
2 columns:
3 period:
4 type: orocrm_period_filter
5 data_name: period
6 options:
7 populate_default: false
8 field_options:
9 choices:
10 monthPeriod: Monthly
11 quarterPeriod: Quarterly
12 yearPeriod: Yearly
13 default:
14 period: { value: monthPeriod }
Additional Params¶
filter_condition - use OR or AND operator in expression
filter_by_having - filter expression should be added to HAVING clause
options - pass form options directly to filter form type (for additional info, see Filter Form Types).
Filters¶
String Filter¶
Provides filtering using string comparison.
type: string - Validated by TextFilterType in backend and rendered by Oro.Filter.ChoiceFilter. When case_insensitive is set to false, it is possible to convert value by using callback defined in ‘value_conversion’.
Select Row Filter¶
Provides filtering by selected/not selected records
type: string - Validated by SelectRowFilterType in backend.
Number and Percent Filter¶
Provides filtering by numbers comparison.
Note
Value from frontend will automatically transform to percentage for “percent” filter.
type: number - integer/decimal filter
Validated by NumberFilterType in backend and rendered by Oro.Filter.NumberFilter.
type: number-range - integer/decimal filter
type: percent - percent filter
type: currency - currency filter
Validated by NumberRangeFilterType in backend and rendered by Oro.Filter.NumberRangeFilter.
Boolean Filter¶
Provides filtering for boolean values.
type: boolean - Validated by BooleanFilterType in backend and rendered by Oro.Filter.ChoiceFilter with a predefined set of options (yes/no)
Choice Filter¶
Provides filtering data using a list of predefined choices
type: choice - Validated by ChoiceFilterType in backend and rendered by Oro.Filter.ChoiceFilter.
Entity Filter¶
Provides filtering data using list of choices that extracted from database.
type: entity - Validated by EntityFilterType in backend and rendered by Oro.Filter.ChoiceFilter.
Date Filter¶
Provides filtering data by date values
type: date - Validated by DateRangeFilterType. Rendered by Oro.Filter.DateFilter.
DateTime Filter¶
Provides filtering data by datetime values
type: datetime - Validated by DateTimeRangeFilterType. Rendered by Oro.Filter.DateTimeFilter.
DateGrouping Filter¶
Provides grouping dates using list of predefined choices: Day, Month, Quarter, Year
type: datetime - Validated by DateGroupingFilterType in backend and rendered by Oro.Filter.ChoiceFilter.
SkipEmptyPeriods Filter¶
Provides skipping empty data using list of predefined choices: Yes, No
type: choice - Validated by SkipEmptyPeriodsFilterType in backend and rendered by Oro.Filter.ChoiceFilter.
Customization¶
To implement your filter you have to do following:
Develop class that implements
Oro\Bundle\FilterBundle\Filter\FilterInterface
(also there is basic implementation in AbstractFilter class)Register your filter as service with tag { name: oro_filter.extension.orm_filter.filter, type: YOUR_FILTER_TYPE }