This repository was archived by the owner on Jun 1, 2025. It is now read-only.
-
- Notifications
You must be signed in to change notification settings - Fork 118
Single Search Filter
ghiscoding edited this page Dec 12, 2022 · 6 revisions
Some users might want to have 1 main single search for filtering the grid data instead of using multiple column filters. You can see a demo of that below
<angular-slickgrid gridId="grid23" [columnDefinitions]="columnDefinitions" [gridOptions]="gridOptions" [dataset]="dataset" (onAngularGridCreated)="angularGridReady($event.detail)"> </angular-slickgrid> <form class="form-inline"> <div class="form-group"> <label>Single Search: </label> <select class="form-control" name="selectedColumn" [(ngModel)]="selectedColumn" (ngModelChange)="updateFilter()"> <option [ngValue]="field" *ngFor="let field of columnDefinitions">{{field.name}}</option> </select> <select class="form-control" name="selectedOperator" [(ngModel)]="selectedOperator" (ngModelChange)="updateFilter()"> <option [ngValue]="operator" *ngFor="let operator of operatorList">{{operator}}</option> </select> <input type="text" class="form-control" name="searchValue" placeholder="search value" autocomplete="off" (input)="updateFilter()" [(ngModel)]="searchValue"> </div> </form>export class MyComponent { angularGrid: AngularGridInstance; grid: any; dataView: any; columnDefinitions: Column[]; gridOptions: GridOption; dataset: any[]; operatorList: OperatorString[] = ['=', '<', '<=', '>', '>=', '<>']; selectedOperator = '='; searchValue = ''; selectedColumn: Column; angularGridReady(angularGrid: AngularGridInstance) { this.angularGrid = angularGrid; } updateFilter() { if (this.selectedColumn && this.selectedOperator) { const fieldName = this.selectedColumn.field; const filter = {}; const filterArg: FilterCallbackArg = { columnDef: this.selectedColumn, operator: this.selectedOperator as OperatorString, // or fix one yourself like '=' searchTerms: [this.searchValue || ''] }; if (this.searchValue) { // pass a columnFilter object as an object which it's property name must be a column field name (e.g.: 'duration': {...} ) filter[fieldName] = filterArg; } this.angularGrid.dataView.setFilterArgs({ columnFilters: filter, grid: this.angularGrid.slickGrid }); this.angularGrid.dataView.refresh(); } }
Contents
- Angular-Slickgrid Wiki
- Installation
- Styling
- Interfaces/Models
- Testing Patterns
- Column Functionalities
- Global Grid Options
- Localization
- Events
- Grid Functionalities
- Auto-Resize / Resizer Service
- Resize by Cell Content
- Composite Editor
- Context Menu
- Custom Tooltip
- Add/Delete/Update or Highlight item
- Dynamically Change Row CSS Classes
- Excel Copy Buffer
- Export to Excel
- Export to File (CSV/Txt)
- Grid State & Presets
- Grouping & Aggregators
- Row Detail
- SlickGrid Controls
- SlickGrid Plugins
- Pinning (frozen) of Columns/Rows
- Tree Data Grid
- SlickGrid & DataView objects
- Addons (controls/plugins)
- Backend Services