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

ng2-paging-table

v4.2.0

Published

> This angular module is to empover table pagination.

Downloads

43

Readme

Ng2PagingTableModule

This angular module is to empover table pagination.

For now, one component is added in this library

  <ng2-paging-table (onColumnSettingsChange)="onColumnSettingsChange($event)" (onRowClick)="onRowClick($event)" [config]="config" [dataSource]="dataSource"></ng2-paging-table>

How to use?

  • Include our ng2-paging-table module in app.module.ts
import { Ng2PagingTableModule } from 'ng2-paging-table';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    Ng2PagingTableModule //<-- add the module in imports
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  • Declare settings and datasource in app.component.ts
//app.component.ts
export class AppComponent {
  config:any={
    enableCheck:true,// it enable check box selection for each row
    showLoading: true,
    paging: {perPage:[10,50,100,500]},
    columns:[
      { "field": "index", "title": "Sr.N", "filter": true, "type": "number" },
      {"field":"id","title":"ID","filter":true,"type":"string"},
      {"field":"name","title":"Name","filter":true,"type":"string"},
      {"field":"country","title":"Country","filter":true,"type":"string"},
      {"field":"city","title":"City","filter":true,"type":"string","hide":true},
      {"field":"date","title":"Date","filter":true,"type":"date",'dateFormat':'medium'}
     ]
  };
  dataSource:any[]=[
     {"id":1,"name":"Yahya Mayo","country":"PK","city":"Lahore","date":"2020-04-18"}
    ,{"id":2,"name":"Hafiz Imran","country":"India","city":"Dehli","date":"2020-04-18"}
    ,{"id":3,"name":"Muhammad Afzal","country":"United Kingdom","city":"London","date":"2020-04-18"}
    ,{"id":4,"name":"Muhammad Akram","country":"United States","city":"New York","date":"2020-04-18"}
    ,{"id":5,"name":"Sikandar Hayat","country":"Italy","city":"Milan","date":"2020-04-18"}
    ,{"id":6,"name":"Malik Asif","country":"Jordan","city":"Berot","date":"2020-04-18"}
    ,{"id":7,"name":"Danish Ilyas","country":"Turkey","city":"Istanbul","date":"2020-04-18"}
    ,{"id":8,"name":"Sajid Masood","country":"Germany","city":"Berlin","date":"2020-04-18"}
    ,{"id":9,"name":"Ghazanfar Puno","country":"France","city":"Paris","date":"2020-04-18"}
    ,{"id":10,"name":"Altaf Totta","country":"Bangladesh","city":"Dhakka","date":"2020-04-18"}
    ,{"id":11,"name":"Umair Khan","country":"Spain","city":"Madrid","date":"2020-04-18"}
  ];
  constructor(){
  }
   onRowClick(item){
    console.log(item)
  }
}
  • app.component.html
<div style="text-align:center">
  <ng2-paging-table (onColumnSettingsChange)="onColumnSettingsChange($event)" (onRowClick)="onRowClick($event)" [config]="config" [dataSource]="dataSource"></ng2-paging-table>
</div>

Direct API Integration?

config:any={
    enableCheck:true,
    fixedHeader:{enable:true,height:400},    
    showLoading: true,
    paging: {perPage:[10,50,100,500]},
    enablePagingWithApi: true,
    columnSettings:true,
    apiSettings: {
      response:{success:Boolean,data:Array,recordsTotal:Number},
      request:"GET",  //Currently it supports get request
      url: "http:/localhost:4520/tracker/getTrackers?length=someValue&start=someValue", //complete url of API endpoint
      params: [{name:"search",value:"Happy life"}],//Mention your params this way i.e name,value
      headers: { }//put your headers here i.e Authorization etc
    },
    columns:[
      { "field": "index", "title": "Sr.N", "filter": true, "type": "number","sorting":true },
      {"field":"id","title":"ID","filter":true,"type":"string","sorting":true},
      {"field":"name","title":"Name","filter":true,"type":"string","sorting":true},
      {"field":"country","title":"Country","filter":true,"type":"string","sorting":true},
      {"field":"city","title":"City","filter":true,"type":"string","sorting":true},
      {"field":"date","title":"Date","filter":true,"type":"date",'dateFormat':'medium',"sorting":true}
     ]
  };
  
  • Example Sample

    sample image

Thank you, give a try. Welcome!

What's next?

  • Refresh table on insert or delete a record without reloading all data
  • Pagination with direct APIs

Contact us?