File

src/ui/filter/smart-filter.component.ts

Extends

AbstractFormChild

Implements

ISmartFilter OnInit OnDestroy AfterViewInit

Metadata

Index

Properties
Methods
Inputs
Outputs
HostListeners
Accessors

Constructor

constructor(registry: SmartFilterRegistry, injector: Injector, elementRef: ElementRef, renderer: Renderer2, screenService: SmartScreenService, changeDetector: ChangeDetectorRef, filterHelper: SmartFilterHelperService)
Parameters :
Name Type Optional
registry SmartFilterRegistry No
injector Injector No
elementRef ElementRef No
renderer Renderer2 No
screenService SmartScreenService No
changeDetector ChangeDetectorRef No
filterHelper SmartFilterHelperService No

Inputs

filter-fields-initial
Type : [] | string

The initial filter fields that the Smart Filter should display.

filter-fields-optional
Type : [] | string

The optional filter fields that the Smart Filter should allow to be set.

orientation
Type : string

The Smart Filter's orientation. Possible values: horizontal, vertical (default).

smart-alternative-controls
Type : Record<string | any>
smart-filter-operators
Type : literal type[]
smart-filter-style
Type : any
smart-help-url
Type : string
smart-object-name
Type : string

The name that the Smart Filter will use to register itself with the SmartFilterRegistry.

title
Type : string

The title to be displayed by the Smart Filter

ignoreFlexboxLayout
Type : boolean
smart-help-text
Type : string | undefined

Sets the HelpText value for this form child.

smart-instance-name
Type : string

The instance name of the component

Outputs

on-filter
Type : EventEmitter<FilterEvent>

Fires when the user clicks the "filter" button.

HostListeners

keypress
Arguments : '$event'
keypress(ev: KeyboardEvent)
Parameters :
Name Optional
ev No

Methods

computeOptionalFilters
computeOptionalFilters()
Returns : any
fireFilterEvent
fireFilterEvent()

Fires the filtered event.

Returns : void
Public getAlternativeControl
getAlternativeControl(filter: any)
Parameters :
Name Type Optional
filter any No
Returns : any

string[]

getFilterBtnClass
getFilterBtnClass()
Returns : "col-4" | "col-6"
getFilterDisplay
getFilterDisplay(field: string)
Parameters :
Name Type Optional
field string No
Returns : any
Public getInputType
getInputType(filter: any)

Returns the appropriate HTML input type for a given filter, according to it's filter field type.

Parameters :
Name Type Optional
filter any No
Returns : any
getOperators
getOperators(filter: any)

Returns a list of possible operators than can be applied to a given filter, according to it's filter field type.

Parameters :
Name Type Optional
filter any No
Returns : any[]
getOptionalFilters
getOptionalFilters()

Returns a list of all possible optional filter field names.

Returns : string[]
Public getTitle
getTitle(filter: any)

Returns the filter field's title from the JSDO schema.

Parameters :
Name Type Optional
filter any No
Returns : string
Public handleLayoutChange
handleLayoutChange(newLayout: any)
Parameters :
Name Type Optional
newLayout any No
Returns : void
initializeFromDataSource
initializeFromDataSource(dataSource: SmartDataSource)

Initializes from the given Smart Data Source. Intended to be called by the Smart Data Source itself. Sets the JSDO schema and initializes the filters accordingly.

Parameters :
Name Type Optional
dataSource SmartDataSource No
Returns : void
insertOptionalFilter
insertOptionalFilter(field: string, operator: string, value?: string)

Displays the specified optional filter field and sets the given operator (defaults to 'eq') and the given value, if any.

Parameters :
Name Type Optional Default value
field string No
operator string No 'eq'
value string Yes
Returns : void
Public keyUpListener
keyUpListener(ev: KeyboardEvent)
Decorators :
@HostListener('keypress', ['$event'])
Parameters :
Name Type Optional
ev KeyboardEvent No
Returns : void
removeFilters
removeFilters()

Removes all filter field values.

Returns : void
removeOptionalFilter
removeOptionalFilter(filter: number | string | any)

Removes an optional filter field from the Smart Filter's template.

Parameters :
Name Type Optional
filter number | string | any No
Returns : void
resize
resize()
Returns : void
setFilterValue
setFilterValue(filter: any, value: any)

Sets the given value to the given filter object.

Parameters :
Name Type Optional
filter any No
value any No
Returns : void
toggleOptionalFilter
toggleOptionalFilter(filter: literal type)

Toggles displaying of the given filter field in the Smart Filter's template.

Parameters :
Name Type Optional
filter literal type No
Returns : void
Public notifyLoadingFinished
notifyLoadingFinished(objectName: string)

Notifies the parent Smart Form that this form child has finished loading

Parameters :
Name Type Optional
objectName string No
Returns : void

void

Properties

filters
Type : unknown
Default value : signal<any[]>([])
filterSize
Type : string
flexDirection
Type : string
operatorMap
Type : any
Default value : { startswith: 'Starts With', eq: 'Equals', contains: 'Contains', gte: 'At least', lte: 'At most', gt: 'Greater Than', lt: 'Less Than', endswith: 'Ends With' }
optFilters
Type : literal type[]
Default value : []
Public injector
Type : Injector

Accessors

filterStyle
getfilterStyle()
Returns : any
setfilterStyle(style: any)
Parameters :
Name Type Optional
style any No
Returns : void
initialFilterFields
getinitialFilterFields()
Returns : string[]
setinitialFilterFields(value: string[] | string)

The initial filter fields that the Smart Filter should display.

Parameters :
Name Type Optional
value string[] | string No
Returns : void
optionalFilterFields
getoptionalFilterFields()
Returns : string[]
setoptionalFilterFields(value: string[] | string)

The optional filter fields that the Smart Filter should allow to be set.

Parameters :
Name Type Optional
value string[] | string No
Returns : void
availableOptionalFilterFields
getavailableOptionalFilterFields()

Returns a list of optional filter field names that have not yet been displayed by the Smart Filter

Returns : string[]
orientation
getorientation()
Returns : string
setorientation(value: string)

The Smart Filter's orientation. Possible values: horizontal, vertical (default).

Parameters :
Name Type Optional
value string No
Returns : void
helpUrl
gethelpUrl()

Gets the help URL for the filter component.

Returns : string
sethelpUrl(value: string)
Parameters :
Name Type Optional
value string No
Returns : void
filterWidthCssClass
getfilterWidthCssClass()
Returns : string
<!--
**************************************************************************
* Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") -                  *
* www.consultingwerk.com and other contributors as listed                *
* below. All Rights Reserved.                                            *
*                                                                        *
*  Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY        *
*   KIND, either express or implied.                                     *
*                                                                        *
*  Contributors:                                                         *
*                                                                        *
**************************************************************************

--------------------------------------------------------------------------
    File        : smart-filter.component.html
    Purpose     : Template for Smart Filter.
    Author(s)   : Radu Nicoara
    Created     : Feb 22, 2018
--------------------------------------------------------------------------
-->
@if (orientation && orientation === 'vertical') {
    <div class="smart-filter vertical zoom-scroll-guard" [ngStyle]="filterStyle" style="padding-inline: 0;">
        <form class="k-form" style="padding-inline: 0;">
            @for (filter of filters(); track filter.field ?? $index) {
                <VerticalField 
                    [filter]="filter"
                    [title]="filter.title"
                    [inputType]="filter.inputType"
                    [operators]="filter.operators"
                    [alternativeControl]="filter.alternativeControl"
                    [filterInstanceName]="instanceName || objectName"
                    [onFilterValueChange]="setFilterValue.bind(this)">
                </VerticalField>
            }
            <div class="text-end" style="padding-top: 10px;">
                <kendo-buttongroup>
                    <button kendoButton type="button" themeColor="primary" [class]="'btn-filter-command'" (click)="fireFilterEvent()">Apply</button>
                    <button kendoButton [class]="'btn-filter-command'" (click)="removeFilters()">Clear</button>
                </kendo-buttongroup>
                @if (optionalFilterFields && optionalFilterFields.length > 0) {
                    <kendo-dropdownbutton 
                        [class]="'btn-filter-command'" 
                        [data]="optFilters"
                        [popupSettings]="{ popupClass: 'optional-filters-dropdown' }"
                        (itemClick)="toggleOptionalFilter($event)"
                        style="margin-left: var(--kendo-spacing-1, 0.25rem);">
                        <span class="fa-solid fa-plus"></span>
                        <ng-template kendoDropDownButtonItemTemplate let-dataItem>
                            <div class="k-form-field">
                                <input kendoCheckBox type="checkbox" [ngModel]="dataItem.enabled()" [ngModelOptions]="{standalone: true}" />
                                <label class="k-checkbox-label">{{dataItem.display}}</label>
                            </div>
                        </ng-template>
                    </kendo-dropdownbutton>
                }
            </div>
        </form>
    </div>
}
@if (orientation && orientation === 'horizontal') {
    <div class="smart-filter horizontal container-fluid px-0" [ngStyle]="filterStyle">
        <div class="row gx-2 mx-0 align-items-end" [ngStyle]="{ flexDirection: 'row', display: 'flex', flexWrap: 'wrap' }" >
            @for (filter of filters(); track filter.field ?? $index; let first = $first) {
                <div class="col-12 col-md" [class.ps-0]="first">
                    <HorizontalField
                        [filter]="filter"
                        [title]="filter.title"
                        [inputType]="filter.inputType"
                        [operators]="filter.operators"
                        [alternativeControl]="filter.alternativeControl"
                        [filterInstanceName]="instanceName || objectName"
                        [onFilterValueChange]="setFilterValue.bind(this)">
                    </HorizontalField>
                </div>
            }
            <div class="horizontal-field-wrapper col-auto pe-0">
                <div class="k-form-field mb-0" style="padding-top: 0;">
                    <label class="k-form-label" style="visibility: hidden; height: 0; margin: 0; padding: 0;">&nbsp;</label>
                    <div style="margin-top: 2px;">
                    <kendo-buttongroup>
                        <button kendoButton [class]="'btn-filter-command'" themeColor="primary" (click)="fireFilterEvent()">
                            Apply
                        </button>
                        <button kendoButton [class]="'btn-filter-command'" (click)="removeFilters()">
                            Clear
                        </button>
                    </kendo-buttongroup>
                    @if (optionalFilterFields && optionalFilterFields.length > 0) {
                        <kendo-dropdownbutton 
                            [class]="'btn-filter-command'" 
                            [data]="optFilters"
                            [popupSettings]="{ popupClass: 'optional-filters-dropdown' }"
                            (itemClick)="toggleOptionalFilter($event)"
                            style="margin-left: var(--kendo-spacing-1, 0.25rem);">
                            <span class="fa-solid fa-plus"></span>
                            <ng-template kendoDropDownButtonItemTemplate let-dataItem>
                                <div class="py-1">
                                    <kendo-checkbox #checkbox [ngModel]="dataItem.enabled()" [ngModelOptions]="{standalone: true}" (ngModelChange)="toggleOptionalFilter($event)">
                                    </kendo-checkbox>
                                    <kendo-label class="k-checkbox-label" [for]="checkbox">{{dataItem.display}}</kendo-label>
                                </div>
                            </ng-template>
                        </kendo-dropdownbutton>
                    }
                    <!-- The invisible input is for avoiding the error from SCLNG-152 -->
                    <input kendoTextBox style="display: none;">
                    </div>
                </div>
            </div>
        </div>
        <kendo-resize-sensor (resize)="resize()"></kendo-resize-sensor>
    </div>
}

./smart-filter.component.css

/**********************************************************************
 * Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") -              *
 * www.consultingwerk.com and other contributors as listed            *
 * below. All Rights Reserved.                                        *
 *                                                                    *
 *  Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY    *
 *   KIND, either express or implied.                                 *
 *                                                                    *
 *  Contributors:                                                     *
 *                                                                    *
 **********************************************************************/
/*------------------------------------------------------------------------
    File        : smart-filter.component.css
    Purpose     : Styles for Smart Filter.
    Author(s)   : Radu Nicoara
    Created     : Feb 22, 2018
  ----------------------------------------------------------------------*/

::ng-deep .filter-btns-wrap { 
    padding: 0px; 
    position: absolute; 
    bottom: 0; 
    right: 0; 
}
::ng-deep .filter-field { padding-left: 0px !important; padding-right: var(--kendo-spacing-1, 0.25rem) !important; }
::ng-deep .bolded { font-weight: var(--kendo-font-weight-semibold, 600); }
::ng-deep .filter-toggle { border-right: none; border-radius: 0px }
::ng-deep .filter-toggle-first { border-right: none; border-radius: var(--kendo-border-radius-md, 0.25rem) 0px 0px var(--kendo-border-radius-md, 0.25rem); }
::ng-deep .filter-toggle-item { cursor: default !important }
::ng-deep .btn-filter-command { padding: var(--kendo-spacing-1.5, 0.375rem) !important }

::ng-deep input, ::ng-deep label {
    font-weight: normal !important;
}
::ng-deep .optional-filters-dropdown .k-form-field {
    margin-bottom: var(--kendo-spacing-1, 0.25rem);
}

::ng-deep .optional-filters-dropdown .k-form-field:last-child {
    margin-bottom: 0;
}

../common/styles/zoom-scroll-guard.scss

/**********************************************************************
 * Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") -              *
 * www.consultingwerk.com and other contributors as listed            *
 * below. All Rights Reserved.                                        *
 *                                                                    *
 *  Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY    *
 *   KIND, either express or implied.                                 *
 *                                                                    *
 *  Contributors:                                                     *
 *                                                                    *
 **********************************************************************/
/*------------------------------------------------------------------------
    File        : zoom-scroll-guard.scss
    Purpose     : Styles for zoom scroll guard.
    Author(s)   : Oana Sucigan
    Created     : Nov 28, 2025
  ----------------------------------------------------------------------*/

.zoom-scroll-guard {
    contain: layout;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""