0.0.13 • Published 3 years ago

sv-tree-view v0.0.13

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

npm.io

SvTreeView

Table of Contents

Demo


Angular Shortcode

Stackblitz

Installation


Install with NPM

npm i sv-tree-view

Options


NameTypeDefault ValueDescription
treeListArrayReference-1
fieldNamestringlabel
checkboxbooleanfalse
draggablebooleanfalse
autoCheckbooleanfalse
customTemplateTemplateReference-2
@Output() rowClickTree
@Output() rowExpandTree
@Output() rowSelectTree
@Output() changeRowIndeterminateStatusTree

Reference

  1. Tree Interface
interface Tree {
  [key: string]: any;
  expanded?: boolean;
  disabled?: boolean;
  selected?: boolean;
  children?: Array<Tree>;
}
  1. Template example
<ng-template #template let-data="data">
  <label>{{data.label}}</label>
</ng-template>

Usage


Import SvStarRatingModule in your app

import { SvTreeViewModule } from 'sv-tree-view';

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

Example


Simple Usage

<sv-tree-view
  [treeList]="treeList"
  [autoCheck]="true"
  [checkbox]="true"
  [draggable]="true"
  (rowClick)="rowClick($event)"
  (rowExpand)="rowExpand($event)"
  (changeRowIndeterminateStatus)="changeRowIndeterminateStatus($event)">
</sv-tree-view>

Custom Template Usage

<sv-tree-view
  [treeList]="treeList"
  [customTemplate]="template"
  (rowClick)="rowClick($event)">
  <ng-template #template let-data="data">
    <div style="display: flex; justify-content: space-between; align-items: center; width: 100%">
      <div style="display: flex; align-items: center">
        <img style="width: 25px; height: 25px; border-radius: 50%; margin-right: 8px" *ngIf="data.image" [src]="data.image" alt="Avatar">
        {{data.label}}
      </div>
      <div *ngIf="data?.children?.length" style="background-color: #ececec; border-radius: 50%; padding: 2px 8px">
        {{data?.children?.length}}
      </div>
    </div>
  </ng-template>
</sv-tree-view>

Author


Mehdi Sadeghian Samira Vahidi

Contact


github

linedIn

comment: <> (twitter)

Keywords


Shortcode Angular