-
Notifications
You must be signed in to change notification settings - Fork 0
String operation filter
The StringOperationFilter class is a concrete implementation of the AbstractOperationFilter class. It is designed to handle string-based filtering operations, such as equality or "like" operations. This class allows for filtering string data using either exact matches or pattern matching.
This class extends the generic AbstractOperationFilter class and specializes in string-based filtering.
constructor(column: string, label: string, conditions?: Condition[])-
column: string: The name of the column or field that the filter applies to. -
label: string: The label or display name for the filter. -
conditions?: Condition[]: An optional array of conditions to initialize the filter with.
Only one condition is allowed for operation filters. If more than one condition is provided, a RangeError will be thrown by the parent class constructor.
protected _conditions: Condition[] = [];-
Type:
Condition[] - Description: The internal array of conditions for the filter. This filter allows only a single condition.
onApply: EventEmitter;-
Type:
EventEmitter - Description: Emits an event when the filter is applied.
apply(value: string, operation: EqualOperation | LikeOperation): void;-
Type:
void - Description: Applies a string-based condition to the filter. This method sets a new condition using the provided string value and operation and overwrites any existing conditions. It also emits an event signaling that the filter has been applied.
-
Parameters:
-
value: string: The string value to compare or check for a match. -
operation: EqualOperation | LikeOperation: The operation to be applied, either an equality operation or a "like" operation for pattern matching.
-
The apply method updates the filter's conditions with the given string value and operation, and then emits the onApply event to indicate that the filter has been applied.
The StringOperationFilter class is useful for filtering string-based fields in a dataset. It provides functionality to filter by both equality (exact match) and "like" operations (partial match).
Suppose you want to filter a dataset based on names that start with "John" using a "like" operation:
const nameFilter = new StringOperationFilter("name", "Name Filter");
nameFilter.apply("John", LikeOperation.StartsWith); // Filters for names that start with 'John'