Mat-Table, HTML Table, AND/OR Logic Filter, Angular Table Filter
AND/OR Logic Table Filter
This blog will give the complete details on using AoL filter which is created for filtering data based on multiple conditions.
AND/OR Logic Table Filter is a modernised version of the HTML Table Filter generator javascript plugin. This library adds to any HTML table a "filter by column", "filter by value", "filter by date" feature that enables users to filter and limit the data displayed within the long table.
This filter doesn't display table, it will only gives a button or icon based on your requirement and it is user friendly. The add on feature in this package is you can filter value by date range and the complete filter is designed in such a way that it adopts CSS styles provided in configuration.
Filter For
Getting started
You can create a new project by following below instructions or download the Github project from test-filter.
Create an Angular project using
ng new test-filter
npm install
npm i bootstrap
After installing the package add "./node_modules/bootstrap/dist/css/bootstrap.min.css" inside "styles" in angular.json file.
"styles": ["./node_modules/bootstrap/dist/css/bootstrap.min.css",...]
ng add @angular/material
ng serve
The application will start in the default port 4200. Open your favourite browser then type
http://localhost:4200/
Install aot-filter to your project
aol-filter
Navigate to above link and follow the instructions to know how to install aol-filter package in your application and install.
Module file configuration
Now it's time to configure HTML table in your project. Open app.module.ts file and add import BrowserAnimationsModule, FormsModule, ReactiveFormsModule, MatMenuModule, MatButtonModule, AotFilterModule.
Component file configuration
Open app.component.ts file and add ELEMENT_DATA.
Add a variable displayColumns that holds the header names of table
Now configure the filterInput variable which actually gives the information to aol-filter on the data to be displayed and custom styles.
AotFilter is a namespace provided from AotFilterModel which provide type details for the variables. Add it to you component as shown below.
import { AotFilterModel } from 'aot-filter';
If you want to use default filter without any custom styles then remove keys that hold the css class i.e
textClass, iconCss, headerCss, matMenuFilterCss, clearTextCss, chipCss, chipCssSelected.
Create a method that will return filtered data on aol-filter event change.
HTML file configuration
Open app.component.html and add the table that display the dataSource in app.component.ts.
Now import the selector <lob-aot-filter> provided from aol-filter.
filterInput is the input accepted from aol-filter that will display the filter based on the configuration.
aotFilterResponse is an event generated on clicking any value on filter. Filtered data can be accessed in onFilterApply method in app.component.ts.
CSS file configuration
KeyWords
AOL Filter ScreenShot
Demo Video
Contact Details
For more details please write us on aish.anu16@gmail.com
Comments
Post a Comment