Hello,
I have set up default filters on a section by following these links:
https://customerfx.com/article/programmatically-overriding-or-adding-fi…
https://community.creatio.com/questions/default-filter-section
Is there a way to filter records with folders in addition to the default filter made in getFilters?
Here is my getFilters method:
getFilters: function() { var filters = this.callParent(arguments); filters.logicalOperation = this.Terrasoft.LogicalOperatorType.OR; filters.add("FilterByAM", this.Terrasoft.createColumnFilterWithParameter( this.Terrasoft.ComparisonType.EQUAL, "MQAccountManager.Id", Terrasoft.SysValue.CURRENT_USER_CONTACT.value )); if (this.get("CanAssignAccountManager")) { filters.add("FilterByManager", this.Terrasoft.createColumnFilterWithParameter( this.Terrasoft.ComparisonType.EQUAL, "MQManager.Id", Terrasoft.SysValue.CURRENT_USER_CONTACT.value )); } return filters; }
Kind regards,
Julien
Like
Hi Julien,
Yes, the filter from folders will get appended to the filters you set for the section. You just need to add your filters in a filter group so they are properly applied as a whole, in addition to the folder filters - rather than just add the filters individually to the filters returned from callParent. For example:
getFilters: function() { var filters = this.callParent(arguments); // now create a filter group for your filters var customFilters = Ext.create("Terrasoft.FilterGroup"); customFilters.logicalOperation = Terrasoft.LogicalOperatorType.AND; customFilters.add("ActiveFilter", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.EQUAL, "Active", true ) ); customFilters.add("NoWidgetFilter", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.NOT_EQUAL, "Type.Name", "Widget" ) ); // now add your filter group to the filters that get returned filters.add(customFilters); return filters; }
It does work without a filter group if you're just adding a single condition, however, in your code you're "OR"ing all your new conditions together with the folder conditions. Using a separate group keeps it all grouped with the same conditions and will work as expected.
Ryan
Hi Julien,
Yes, the filter from folders will get appended to the filters you set for the section. You just need to add your filters in a filter group so they are properly applied as a whole, in addition to the folder filters - rather than just add the filters individually to the filters returned from callParent. For example:
getFilters: function() { var filters = this.callParent(arguments); // now create a filter group for your filters var customFilters = Ext.create("Terrasoft.FilterGroup"); customFilters.logicalOperation = Terrasoft.LogicalOperatorType.AND; customFilters.add("ActiveFilter", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.EQUAL, "Active", true ) ); customFilters.add("NoWidgetFilter", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.NOT_EQUAL, "Type.Name", "Widget" ) ); // now add your filter group to the filters that get returned filters.add(customFilters); return filters; }
It does work without a filter group if you're just adding a single condition, however, in your code you're "OR"ing all your new conditions together with the folder conditions. Using a separate group keeps it all grouped with the same conditions and will work as expected.
Ryan