2.0.5 • Published 2 years ago

ngm-tree-grid v2.0.5

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

NgmTreeGrid

A tree grid that supports editable fields like Inputs and Checkboxes.

Demo

You can find Demo here.

It shows your kindness if you give star on my github. I will appreciate that. You can find Repo here.

Version

For Angular version 14 use version 2 of this library

Installation

Install ngm-tree-grid with npm

  cd my-project
  npm i ngm-tree-grid
  npm i ngm-live-search

Usage/Examples

import { NgmTreeGridModule } from "ngm-tree-grid";

@NgModule({
  imports: [NgmTreeGridModule],
})
export class AppModule {}

Then in your component.html

<div class="tree-grid">
  <ngm-tree-grid
    [dataSource]="dataSource"
    [config]="treeGridConfig"
    (expand)="onExpand($event)"
    (collapse)="onCollapse($event)"
  >
    <ng-template #treeGridHeader>
      first header
    </ng-template>
    <ng-template #treeGridHeader>
      second
    </ng-template>
    <ng-template #treeGridCell let-item>
      <div>{{ item.title.caption }}</div>
    </ng-template>

    <ng-template #treeGridCell let-item>
      <input type="checkbox" />
    </ng-template>
  </ngm-tree-grid>
</div>

Then in your component put

export class YourComponent {
  dataSource = new NgmDataSource();
  getChildrenFn = (obj: any) => obj.nodes ?? [];
  treeGridConfig: INgmTreeGridConfig = {
    columns: [
      {
        header: "Title: ",
        width: 50,
      },
      {
        header: "Id: ",
        width: 50,
      },
    ],
    searchFn: (item, text: string) =>
      item.name.toLocaleLowerCase().includes(text.toLocaleLowerCase()),
  };

  data = [
    {
      id: 1,
      name: "Mostafa",
      nodes: [
        {
          id: 2,
          name: "Soleimani",
        },
      ],
    },
  ];

  ngOnInit() {
    this.dataSource.data = this.data;
    this.dataSource.getChildrenFn = (obj: any) => obj.nodes ?? [];
  }

  onExpand(e: INgmExpansion) {
    console.log("expand:   ", e);
  }

  onCollapse(e: INgmExpansion) {
    console.log("collapse:   ", e);
  }
}

API Reference

Inputs and Outputs

ParameterTypeDescription
[config]INgmTreeGridConfigconfiguration of tree-grid header and search
[dataSource]INgmDataSourcedata and a func to get children
(expand)Outputemits when user expand a node returns the item
(collapse)Outputemits when user collapse a node returns the item
2.0.5

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago