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

@thecreatiiives/angular-material-datatable

v0.0.7

Published

Angular material data table with pre-integrated search, sort, pagination server side and also with customized columns width, colors, font and border style...

Downloads

6

Readme

Angular Material Datatable

Angular material data table with pre-integrated search, sort, pagination server side and also with customized columns width, colors, font and border style...

Instalation

This instruction will allow you to use our awesome data table:

First you need to install Angular Material Package - With this commande:

npm i @angular/material

Choose any theme you want we recommend deeppurple-amber

and tap yes for the next tow steps

and then install our package

npm i @thecreatiiives/angular-material-datatable

and import it in your app module

import { AngularMaterialDatatableModule } from '@thecreatiiives/angular-material-datatable';
....
@NgModule({
  ....
  imports: [
    ....
    AngularMaterialDatatableModule,
    ....
  ],
  ....
})

cheers now you can use the datatable ^ ^

Usage

First you need to create a service

Example

getDatas(search, sortType, sortBy, page, maxRows) {
    return this.http.post('http://datatablepagination.test/api/users', {
        search,
        page,
        maxRows,
        sortBy,
        sortType
    });
}

this API should return this format

{
    "data":[
        {
            "id":29,
            "firstname":"Aida",
            "lastname":"Kutch",
            ....
        }
    ],
    "per_page":5,
    "total":50
}

and also a Datasource

Example

import {CollectionViewer, DataSource} from '@angular/cdk/collections';
import { BehaviorSubject, Observable } from 'rxjs';
import { ExampleDataTableService } from './example-data-table.service';

export class ExampleDataTableDatasource implements DataSource<any> {
    public datasSubject = new BehaviorSubject([]);
    public loadingSubject = new BehaviorSubject<boolean>(false);

    constructor(private exampleDataTableService: ExampleDataTableService) {}

    connect(collectionViewer: CollectionViewer): Observable<any> {
        return this.datasSubject.asObservable();
    }

    disconnect(collectionViewer: CollectionViewer): void {
        this.datasSubject.complete();
        this.loadingSubject.complete();
    }

    loadDatas(
        filter = '',
        sortDirection = 'asc',
        column = 'firstname',
        pageIndex = 0,
        pageSize = 5
    ) {
        this.loadingSubject.next(true);

        return this.exampleDataTableService.getDatas(
            filter,
            sortDirection.toUpperCase(),
            column,
            pageIndex,
            pageSize
        );
    }
}

and finaly use the datatable in your component

Component.ts

import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router';
import { ExampleDataTableDatasource } from './example-data-table.datasource';
import { ExampleDataTableService } from './example-data-table.service';
import {MatSnackBar} from '@angular/material/snack-bar';

@Component({
  selector: 'app-example-data-table',
  templateUrl: './example-data-table.component.html',
  styleUrls: ['./example-data-table.component.styl']
})
export class ExampleDataTableComponent implements OnInit {
  dataSource: ExampleDataTableDatasource;
  columns = [
    {
      key: 'firstname',
      value: 'First Name',
      width: '100px'
    }
    ....
  ];
  actions = [
    {
      code: 'add',
      classe: 'add-class',
      icone: 'add',
      name: 'Add'
    }
    ....
  ];
  constructor(private matSnackBar: MatSnackBar, private router: Router, private exampleDataTableService: ExampleDataTableService) {
    this.dataSource = new ExampleDataTableDatasource(this.exampleDataTableService);
  }

  ngOnInit() {
  }

  sendAction($event) {
    console.log($event[0]);
    this.matSnackBar.open($event[1].firstname, $event[0], {
      duration: 3000,
    });
  }

}

Component.html

<div class="container">
    <h3>Data Table Demo</h3>
    <mat-datatable
        [datasource]="dataSource"
        (sendAction)="sendAction($event)"
        cssClass='custom-datatable'
        [columns]='columns'
        [actions]='actions'
        [search]="true"
    >
    </mat-datatable>
</div>

that's all now you can you use our data table with predefined server pagination search sort ...

Hope you like it ^ ^