0.0.8 • Published 6 months ago

@iladiro/angular-material-table-library v0.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

MaterialTableFilter Documentation

This library is compatible with Angular versions >=16.0.0.0

Note: Please use version from 0.0.6, which is compatible with Angular versions >=16.0.0, older versions are only compatible with Angular version ^16.2.7. It was my mistake! Thank you

It is an Angular library based on Material to filter tabular data by columns. Here is an example:

Alt text

Alt text

Alt text

Before start

  1. Make sure to install @angular/material and @angular/cdk
  2. Import a material theme on your preference. Ex: @import '../node_modules/@angular/material/prebuilt-themes/indigo-pink.css';. May not works as expected without it.
  3. Add in your project index.html <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">. It could be impossible to see the material's icons without it.
  4. Import in your module import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
  5. npm i @iladiro/angular-material-table-library
  6. Import a Material theme, on your preference from import { IladiroAngularMaterialTableLibraryModule } from '@iladiro/angular-material-table-library';.

Getting Setup

Use <iladiro-angular-material-table></iladiro-angular-material-table> selector to show table

Interface

Your data is an array of object of your custom interface type. The object's properties must match table columns (es. First Name column is first_name property of your object interface)

For example, this is my custom interface

    interface TableList {
        name: string;
        surname: string;
        gender: string;
        buttons?: IladiroAMTButton[];
    }

Note: buttons property is optional. If you use it, it must be an array of type IladiroAMTButton interface. Import it from import { IladiroAMTButton } from '@iladiro/angular-material-table-library'; Each button's properties are required. If you don't need some property set it as empty string. If we need to use icons, please use material icons.

Example

Default: example with only mandatory data!

<iladiro-angular-material-table [list]="list" [displayedColumns]="['name', 'surname', 'gender', 'buttons']"></iladiro-angular-material-table>

Custom

<iladiro-angular-material-table [inputPlaceholder]="'Filter on'" [filterValues]="filterValues" [customClass]="'myapp'" (callToActionEvent)="callToActionEvent($event)" (appliedFilterEvent)="whatFilter($event)" (paginatorEvent)="paginator($event)" [noResultLabel]="'No results found'" [displayedColumns]="['name', 'surname', 'gender', 'buttons']" [list]="list"></iladiro-angular-material-table>

Options

PropertyTypeRequiredDefaultNotes
listArrayyesundefinedThis widget expect a list to show it.
displayedColumnsArray<string>yesundefinedTo show columns in the table you have to pass an array of string where each value match with the properties of the custom interface. Ex: displayedColumns="'name', 'surname', 'gender', 'buttons'".
inputPlaceholderStringnoFind byYou can also pass a placeholder to show into filter input field
customClassStringnoundefinedYou can also pass a class or a list of classes to add to the parent
noResultLabelStringnoNo resultsYou can also pass a custom text to show when no result returned
filterValuesFilter<any>[]no[]If you use store like Ngrx or others, you can save it into store don't lose filters in the case user leave the component to go to another route.
pageIndexnumberno0If you use store like Ngrx or others, you can save it into store don't lose last pageindex in the case user leave the component to go to another route..
showPageSizeOptionsbooleannotrueYou can choose to show or not the page size option
pageSizeOptionsnumber[]no[5, 10, 15]If you set showPageSizeOptions to true you can pass yuour custom page size options
showFirstLastButtonsbooleannotrueYou can choose to show or not first and last paginator's arrow
pageSizenumberno5On your preferences, You can set how many records show for each page
hidePageSizebooleannofalseYou can choose to show or not page size per page element

Events

Event nameReturnDescriptionExample
paginatorEvent{length: 14, pageIndex: 1, pageSize: 5, previousPageIndex: 0}Allows you to capture the event when the paginator is used<iladiro-angular-material-table (paginatorEvent)="console.log($event)"></iladiro-angular-material-table>
callToActionEvent{ icon: "delete", label: "", action: "delete", link: "", title: "Delete"}Allows you to capture the event when click on row's button<iladiro-angular-material-table (callToActionEvent)="console.log($event)"></iladiro-angular-material-table>
appliedFilterEvent{ "filterValues": [ { "value": "ma", "col": "name" } ], "filteredData": [ { "name": "Mario", "surname": "Rossi", "gender": "Maschio", "buttons": [ { "icon": "open_in_new", "label": "Visualizza", "action": "view", "link": "", "title": "View" }, { "icon": "delete", "label": "", "action": "delete", "link": "", "title": "Delete" } ] } ], "length": 1 }Allows you to capture the event when the user use the filter. What return is filters list, filtered data and the array lenght<iladiro-angular-material-table (appliedFilterEvent)="console.log($event)"></iladiro-angular-material-table>
0.0.8

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago