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-bs-table

v1.0.11

Published

Boostrap table view for angular 2.

Downloads

1

Readme

Angular 2 bootstrap table

Install

npm i -S ng2-bs-table

SystemJS usage

paths: {
    // paths serve as alias
    'npm:': 'node_modules/',},
map:{
    'ng2-bs-pagination' : 'npm:ng2-bs-pagination',
    'ng2-bs-table' : 'npm:ng2-bs-table'
},
packages: {
    'ng2-bs-pagination': {
        main: './index.js',
        defaultExtension: 'js'
    },
    'ng2-bs-table': {
        main: './index.js',
        defaultExtension: 'js'
    }
}

Table Selector

  • <table-view></table-view>

You can create table with any data in a cell. For cell can be used data or any components. To import components you can
use [imports] and any modules (ExampleModule, check bellow). For filter can be used default input or can be implemented any other custom filters. Component has many useful events for data management.

Table Settings

  • [collection] - Array - (Default: [])- Data collection of objects
  • [columns] - Array - Array of all columns to be displayed and how to format them for ordering
  • [filters] - Array - (Default: []) - Filters for each column. You can implement own filter if you need or use exists.
  • [actions] - TableActionInterface - (Default: []) - Table actions: For example: view, delete, etc.
  • [transformers] - Array - (Default: []) - Transformers for data.
  • [sorting] - TableViewSorting - Which column to sort on and which direction (ascending or descending)
  • [imports] - Array - (Default: []) - Any additional Modules for imports.
  • [autoPipe] - Boolean - (Default: true) - If you set false then all pipes(transformers) will be disabled.

TableView Example

import {Component, OnInit} from "@angular/core";
import {
    TableViewSorting,
    TableDataColumn,
    TableInputFilter,
    FilterEvent,
    OrderEvent,
    ActionClickEvent,
    TableFilterInterface,
    TableViewComponent,
    TableEmptyAction,
    TableViewAction,
    TableColumnInterface,
    TableActionInterface
} from "ng2-bs-table";
import {StatusColumn} from "./status-column";

@Component({
    moduleId: module.id,
    selector: 'table',
    templateUrl: 'table.component.html'
})
export class TableComponent {
    collection: Array<{}>;

    columns: Array<TableColumnInterface> = [
        new TableDataColumn('Name', 'name', 'text', true),
        new StatusColumn('Type', 'type', true) // Check bellow
    ];

    filters: TableFilterInterface[] = [
        new TableInputFilter('name'),
        new TableInputFilter('type')
    ];

    sorting: TableViewSorting = new TableViewSorting('name', false);

    actions: Array<TableActionInterface> = [
        new TableViewAction('view', 'Edit', null, 'glyphicon glyphicon-pencil'),
        new TableEmptyAction('link', 'Link', null, 'glyphicon glyphicon-remove')
    ];

    onActionClick(event: ActionClickEvent) {
        switch (event.action.name) {
            case 'view':
                break;
            case 'link':
                break;
        }
    }
    
    onCellChange(event: any){
        console.log(event);
    }
    
    onOrder(event: OrderEvent) {
        console.log(event);
    }

    onFilter(event: FilterEvent) {
        console.log(event);
    }

    ngOnInit(): void {
        let collection = [];
        for (let i = 0; i < 1000; i++) {
            collection.push({
                name: i,
                type: 'type ' + i
            });
        }
        this.collection = collection;
    }
}
<table-view
        [columns]="columns"
        [filters]="filters"
        [collection]="collection"
        [sorting]="sorting"
        [actions]="actions"
        (order)="onOrder($event)"
        (filter)="onFilter($event)"
        (cellChange)="onCellChange($event)"
        (actionClick)="onActionClick($event)">
    Loading table...
</table-view>

Events (Check dir events with all events objects)

  • order
  • filter
  • cellChange
  • actionClick
  • pageChange

Actions

You can use actions:

  • TableViewAction - On click will be called to route-
  • TableEmptyAction - On click will be called event-
  • TableVerifyAction - On click will be called to route with confirm-

Custom column

You can use any component if you need. For example ''. You should add to "table-view" in input "imports" some module "SharedModule" with component "TestComponent".

import {TableHtmlColumn} from "ng2-bs-table";

export class StatusColumn extends TableHtmlColumn {
    template(data: Object): string {
        // Or set some component "<test-component></test-component>"
        return '<a routerLink="/admin/templates" routerLinkActive="active">{{data.name}} - {{data.type}}</a>';
    }
}

For custom filter you can Use input filter for example. You need implementing:

  • TableFilterInterface
  • TableFilterInterfacePipe
  • TableFilterInterfaceComponent

ExampleModule

import {AnyModule} from 'some-folder';

@NgModule({
    declarations: [ 
        AnyComponent 
    ],
    exports: [
        AnyComponent
    ],
    providers: [
    ]
})
export class ExampleModule {
}
@Component({
    moduleId: module.id,
    selector: 'test',
    templateUrl: 'test.component.html',
    providers: [PaginationPipe]
})
export class TestComponent{
    ...
    imports = [ ExampleModule ]
    ...
}
// Template example
<table-view
        ...
        [imports]="imports"
        ...        
    Loading table...
</table-view>

Todo

  • Implement webpack. It does not work yet.
  • DropDown filter.