2.2.3 • Published 6 years ago

ng-tree-antd v2.2.3

Weekly downloads
25
License
MIT
Repository
-
Last release
6 years ago

ng-tree-antd

A antd style of based on angular-tree-component.

NPM version Build Status

Demo

Live Demo & stackblitz

Dependencies

  • angular-tree-component ^7.0.1

Usage & Installation

Install ng-tree-antd from npm

npm install ng-tree-antd --save

Import the NzTreeModule in to your root AppModule.

import { NzTreeModule } from 'ng-tree-antd';
import { NgZorroAntdModule } from 'ng-zorro-antd';

@NgModule({
    imports: [BrowserModule, NzTreeModule, NgZorroAntdModule.forRoot()],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }

Usage

import { Component } from '@angular/core';
import { generateData } from './generate-data';

@Component({
  selector: 'demo',
  template: `
  <nz-tree [nzNodes]="nodes"
           [nzOptions]="options"
           (nzEvent)="onEvent($event)"></nz-tree>
  `
})
export class DemoDraggableComponent {
  nodes = [
    {
      name: 'root1'
    },
    {
      name: 'root2'
    },
    {
      name: 'root3'
    },
    {
      name: 'async root4',
      hasChildren: true
    }
  ];

  options = {
    allowDrag: true
  };

  onEvent(ev: any) {
    console.log('onEvent', ev);
  }
}

nzNodes DATA

the nzNodes is array of the tree, and each node may contain the following fileds:

  • id unique id
  • name default displayed filed, you can setting displayField of options property
  • checked specifies whether the checkbox is selected
  • disableCheckbox disable checkbox
  • halfChecked achieve a 'check all' effect
  • children an array of the node's children.
  • hasChildren for async data load, so you need setting getChildren of options property

API

NameTypeDefaultSummary
nzNodesany[]see inputs
nzAutoExpandParentboolean, numberfalse是否自动展开父节点,当数字时展开最大节点
nzAllowChildLinkagebooleantrue是否开启父节点的checkbox状态的会影响子节点状态
nzAllowParentLinkagebooleantrue是否开启子节点的checkbox状态的会影响父节点状态
nzCheckablebooleanfalseAdd a checkbox before the node
nzShowLinebooleanfalseShows a connecting line
nzOptionsTreeOptionssee options
nzTitleTemplateRefCustom title
nzLoadingTemplateRefCustom Loading
nzShiftSelectedMultibooleantrueselected multi when shift key
nzToggleExpandedEventEmittersee events
nzActivateEventEmitter
nzDeactivateEventEmitter
nzFocusEventEmitter
nzBlurEventEmitter
nzUpdateDataEventEmitter
nzInitializedEventEmitter
nzMoveNodeEventEmitter
nzCopyNodeEventEmitter
nzLoadNodeChildrenEventEmitter
nzChangeFilterEventEmitter
nzEventEventEmitter
nzStateChangeEventEmitter
nzCheckEventEmitterfired checkbox is changed

Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

  1. Use GitHub Issues board to report bugs and feature requests (not our email address)
  2. Please always write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for understanding!

License

The MIT License (see the LICENSE file for the full text)