npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mat-table-filter-sort

v0.0.3

Published

A powerful Angular library designed to simplify table management by providing advanced features such as multi-column searching and sorting, which can be used seamlessly together to enhance your data tables effortlessly.

Downloads

9

Readme

MultiFilterSortTable

This npm package is exclusively for Angular based applications. On the bottom, it uses angular mat-table but it offers more than a typical mat-table. The main features it provides is:

  1. Column specific searching / filtering
  2. Multi column searching / filtering
  3. Sorting on multiple columns
  4. Using sorting and filtering with eachother.
  5. It includes a convenient built-in optional feature for action buttons within columns. Simply provide the action button's icon and associated function, and a new column with the button will automatically be appended at the end.

Why is it different and better than mat-table?

It offers multi-column sorting functionality. When sorting data by multiple columns simultaneously, it prioritizes the first-clicked column for sorting and subsequently refines the sorting based on the later-clicked column(s). It indicates the sorting order by showing small numbers beside the column name.

You can also sort the filtered data

Installation

This project uses angular material library as it uses mat-table. It also uses tailwind library for css styling. You can install this package by simply running following commmand:

npm i mat-table-filter-sort

I would suggest to install tailwind as well for seamless experience. To insatll tailwind css with angular, visit following link: https://tailwindcss.com/docs/guides/angular

Usage

How to use this library?

Add following link tags main index.html file present in src folder

<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

To use this library, you need to pass the column and datasource same as you pass in angular mat-table.

<NgxMat-mat-table-filter-sort 
  [dataSource]="datasource"
  [displayedColumns]="displayedColumns"
  [columnsFeatures]="columnsFeatures"
  [sortingIconColor]="'red'"
  [sortingIconSize]="'10px'"
  [handleRowActionButton]="handleRowActionButton"
  [actionDisplayedColumns]="actionDisplayedColumns"
  [actionColumnFeatures]="actionColumnFeatures"
  [actionIcon]="'cached'"
  [multiSearch]="multi_search"
  [mutliSearchFieldPlaceholder]="mutliSearchFieldPlaceholder"
  [singleSearch]="single_search"
  [indexOfSearchingColumn]="single_search_index"
  [singleSearchFieldPlaceholder]="single_search_placeholder"
>
</NgxMat-mat-table-filter-sort> 

- In *.ts file, variables look like this:

datasource = [
  {id: 1, name: 'jon', profession: "Engineer"},
  {id: 2, name: 'Doe', profession: "Doctor"},
  {id: 3, name: 'Mark', profession: "Doctor"},
  {id: 4, name: 'Niah', profession: "Doctor"},
  {id: 5, name: 'Ceecee', profession: "Engineer"},
  {id: 6, name: 'jack', profession: "Doctor"}
]

displayedColumns = ["id", "name", "profession"];

columnsFeatures = ["ID", "Name", "Profession"]; // these names will be displayed as column_title

handleRowActionButton = (element: any) => {
  console.log("Action Button Clicked:", element);
}

actionDisplayedColumns = ["action"] // for now it only works with one element in array, multiple action button columns feature will be added later on demand.

actionColumnFeatures = ["Action"]; these names will be displayed as action_column_title

multi_search: boolean = true; // set to true, shows column specific fields for multi searching features. Must be set true for using multi-search feature

mutliSearchFieldPlaceholder = ["ID", "Name", "Profession"]; // if left empty, the fields stay empty

single_search: boolean = false; // set to true, shows column single field at top of table. Must be set true for using single-search feature

single_search_placeholder: string = ""; // placeholder for the field shown in single-search feature

single_search_index: number = 0; // set this to the index of the column, that you want to use for searching in single-search feature
  • For using icons options, use this link:
https://www.angularjswiki.com/angular/angular-material-icons-list-mat-icon-list/

copy text between mat-icon tags and use it against 'actionIcon' input.

Configuration

You can style the columns and other things by using ng-deep:: feature, support for passing tailwind css will be added later if demanded by the users.

Contributing

  1. Take fork of reporsitory.
  2. Create branch with the name of the feature you want to add or bug you want to resolve, in following format: for feature branch: FEATURE-feature_name for bug solution branch: BUG-bug_title

License

This project is licensed under the MIT - see the LICENSE file for details.

Queries

In case of any questions feel free to start thread on github, or contact me on linked in. And I will try to reach out to you as soon as possible.

Credits

Mirza Haad Baig - owner/author

github: github.com/haadbaig
linkedin: linkedin.com/in/haadbaig
medium.com/@haadbaig
____________________________________