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

ngrid2

v0.0.6

Published

This is a data grid using angular 7 with typescript.

Downloads

5

Readme

NgNgrid2

This is a data grid using angular 7 with typescript More info to come.

You can see the demo here: https://nikhilogic.github.io/ngNgrid2/

To install the library in your project :

  1. Add npm package and dependencies
npm install ngrid2
npm install @angular/http@latest
npm install @ng-bootstrap/ng-bootstrap@latest
npm install npm@latest
  1. Add imports to your app.module.ts
    import { Ngrid2Module } from 'ngrid2';
    ...
    @NgModule({
    ...
    imports: [
        ...
        Ngrid2Module
    ],
    ...
    })
  1. In your app.component.ts
    //Import required types
    ...
    import { Ngrid2ButtonColumn, Ngrid2DefaultColumn, Ngrid2InputColumn, Ngrid2SelectColumn, Ngrid2LinkColumn,  Ngrid2DateColumn,Ngrid2DropdownFilter,INgrid2Row } from 'ngrid2';
    import { MyObjectRow } from './MyObjectRow'; //this will be your (row) class which will implement the INgrid2Row interface 
    // something like 
    // export class MyObjectRow implements INgrid2Row
    // {
    //     Children: INgrid2Row[];    
    //     isNgNgridOpen: boolean;
    //     Index: number;
    //     isNgNgridMarkedForDelete: boolean;
    //     isNgNgridMarkedForNew: boolean;
    //     isNgNgridDirty: boolean;
    //     isNgNgridSelected: boolean;
    //     isNgNgridUpdated: boolean;

    //     Col1: string;
    //     Col2: string;
    //     Col3: string;
    //     Col4 : object;
    //     Col5 : string;      
    //     Col6 : Date;
    //     Col7 : number;
    // }
    ...

    export class AppComponent implements OnInit {
    ...
     // define the variables used for the grid
     columnDefinitions : Ngrid2DefaultColumn[];    //Used for intializing the main columns for the grid
     rows : any[]; //used for setting the rows for the grid
     childColumndefinitions : Ngrid2DefaultColumn[];    //optional: used for setting child columns 
     childPropertynames:  string[];  // optional : used for specifying which property of the main row contains the child rows.
     ...
    
     
     //create column objects (example a button column)
     getButtonCol(): Ngrid2DefaultColumn {
        var btnCol : Ngrid2ButtonColumn = new Ngrid2ButtonColumn();
        btnCol.Name= "Col2",
        btnCol.isNgNgridColumnHide = false,
        btnCol.DisplayName = () => {
        return btnCol.Name;
        };
        btnCol.isNgNgridSelected = false;        
        btnCol.ClassFn  = (r: INgrid2Row) => {
        return "btn-" + r[btnCol.Name];
        };
        btnCol.CellClassFn = (r: INgrid2Row) => {
        return "";
        };
        btnCol.TooltipFn = (r: INgrid2Row) => {      
        return "hello";
        };
        btnCol.BadgeFn = (r: INgrid2Row) => {      
        return r.Index.toString();
        };
        btnCol.BadgeClassFn = (r: INgrid2Row) => {      
        return "badge-dark badge-pill";
        };
        btnCol.BadgeUrlFn = (r: INgrid2Row) => {      
        return "https=//www.bing.com"
        };
        btnCol.BadgeTargetFn = (r: INgrid2Row) => {      
        return "_top"; 
        };
        btnCol.IconFn = (r: INgrid2Row) => {
        return "far fa-play-circle";
        };
        btnCol.NullOrEmptyFn =  (r: INgrid2Row) => {      
        return "No Value";
        }        
        btnCol.FilterClassFn = (d: Ngrid2DropdownFilter) => {      
        return "bg-"  + d.DistinctValue ;
        };
        btnCol.FilterIconFn= (d: Ngrid2DropdownFilter) => {
        return "far fa-play-circle";
        };
        btnCol.NullOrEmptyFn =  (r: INgrid2Row) => {      
            return "No Value";
        }
        btnCol.ClickFn =  (r: INgrid2Row) => {
        alert("clicked");
        };
        btnCol.DisabledFn =  (r: INgrid2Row) => {
        return false;
        }
        return btnCol;
    }
...
 ngOnInit() {           
     
    //set the columns for the grid
    this.columnDefinitions = [];    
    this.rows = [];    
    this.childColumndefinitions = [];
    this.childPropertynames =["Children"];        

    //add column definition for the grid
    this.columnDefinitions.push(this.getButtonCol());

    //create a row for the grid
    var newrow : MyObjectRow = new MyObjectRow();
    newrow.Index = 0;
    newrow.isNgNgridOpen = false;
    newrow.Col2  = "textonbutton";      
    
    //add the row to the grid
    this.rows.push(newrow); 
    ...
 }
  1. In your HTML reference the grid like this
<ng-ngrid2
[columnDefinitions]="columnDefinitions" 
[childColumndefinitions]="childColumndefinitions"
[rows]="rows" 
[showSettings]="false"
[childPropertynames]="childPropertynames"></ng-ngrid2>